tesseract v5.3.3.20231005
gtest-spi.h File Reference
#include "gtest/gtest.h"

Go to the source code of this file.

Macros

#define EXPECT_FATAL_FAILURE(statement, substr)
 
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr)
 
#define EXPECT_NONFATAL_FAILURE(statement, substr)
 
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr)
 

Functions

 GTEST_DISABLE_MSC_WARNINGS_PUSH_ (4251) namespace testing
 

Macro Definition Documentation

◆ EXPECT_FATAL_FAILURE

#define EXPECT_FATAL_FAILURE (   statement,
  substr 
)
Value:
do { \
class GTestExpectFatalFailureHelper {\
public:\
static void Execute() { statement; }\
};\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\

◆ EXPECT_FATAL_FAILURE_ON_ALL_THREADS

#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS (   statement,
  substr 
)
Value:
do { \
class GTestExpectFatalFailureHelper {\
public:\
static void Execute() { statement; }\
};\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ALL_THREADS, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\

◆ EXPECT_NONFATAL_FAILURE

#define EXPECT_NONFATAL_FAILURE (   statement,
  substr 
)
Value:
do {\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
(substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
if (::testing::internal::AlwaysTrue()) { statement; }\
}\
GTEST_API_ bool AlwaysTrue()
Definition: gtest.cc:6240

◆ EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS

#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS (   statement,
  substr 
)
Value:
do {\
::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
(substr));\
{\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
&gtest_failures);\
if (::testing::internal::AlwaysTrue()) { statement; }\
}\

Function Documentation

◆ GTEST_DISABLE_MSC_WARNINGS_PUSH_()

GTEST_DISABLE_MSC_WARNINGS_PUSH_ ( 4251  )

Definition at line 41 of file gtest-spi.h.

44 {
45
46// This helper class can be used to mock out Google Test failure reporting
47// so that we can test Google Test or code that builds on Google Test.
48//
49// An object of this class appends a TestPartResult object to the
50// TestPartResultArray object given in the constructor whenever a Google Test
51// failure is reported. It can either intercept only failures that are
52// generated in the same thread that created this object or it can intercept
53// all generated failures. The scope of this mock object can be controlled with
54// the second argument to the two arguments constructor.
55class GTEST_API_ ScopedFakeTestPartResultReporter
56 : public TestPartResultReporterInterface {
57 public:
58 // The two possible mocking modes of this object.
59 enum InterceptMode {
60 INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures.
61 INTERCEPT_ALL_THREADS // Intercepts all failures.
62 };
63
64 // The c'tor sets this object as the test part result reporter used
65 // by Google Test. The 'result' parameter specifies where to report the
66 // results. This reporter will only catch failures generated in the current
67 // thread. DEPRECATED
68 explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
69
70 // Same as above, but you can choose the interception scope of this object.
71 ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
72 TestPartResultArray* result);
73
74 // The d'tor restores the previous test part result reporter.
75 ~ScopedFakeTestPartResultReporter() override;
76
77 // Appends the TestPartResult object to the TestPartResultArray
78 // received in the constructor.
79 //
80 // This method is from the TestPartResultReporterInterface
81 // interface.
82 void ReportTestPartResult(const TestPartResult& result) override;
83
84 private:
85 void Init();
86
87 const InterceptMode intercept_mode_;
88 TestPartResultReporterInterface* old_reporter_;
89 TestPartResultArray* const result_;
90
91 GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
92};
93
94namespace internal {
95
96// A helper class for implementing EXPECT_FATAL_FAILURE() and
97// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given
98// TestPartResultArray contains exactly one failure that has the given
99// type and contains the given substring. If that's not the case, a
100// non-fatal failure will be generated.
101class GTEST_API_ SingleFailureChecker {
102 public:
103 // The constructor remembers the arguments.
104 SingleFailureChecker(const TestPartResultArray* results,
105 TestPartResult::Type type, const std::string& substr);
106 ~SingleFailureChecker();
107 private:
108 const TestPartResultArray* const results_;
109 const TestPartResult::Type type_;
110 const std::string substr_;
111
112 GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
113};
114
115} // namespace internal
116
117} // namespace testing
#define GTEST_API_
Definition: gtest-port.h:779
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: gtest-port.h:697
type
Definition: upload.py:458