Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest_output_test_.cc File Reference
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
#include <stdlib.h>
Include dependency graph for gtest_output_test_.cc:

Go to the source code of this file.

Classes

class  FailingParamTest
 
class  NonFatalFailureInFixtureConstructorTest
 
class  FatalFailureInFixtureConstructorTest
 
class  NonFatalFailureInSetUpTest
 
class  FatalFailureInSetUpTest
 
class  foo::MixedUpTestCaseTest
 
class  foo::MixedUpTestCaseWithSameTestNameTest
 
class  bar::MixedUpTestCaseTest
 
class  bar::MixedUpTestCaseWithSameTestNameTest
 
class  TEST_F_before_TEST_in_same_test_case
 
class  TEST_before_TEST_F_in_same_test_case
 
class  ParamTest
 
class  ExpectFailureTest
 
class  FooEnvironment
 
class  BarEnvironment
 

Namespaces

namespace  foo
 
namespace  bar
 

Functions

void TestEq1 (int x)
 
void TryTestSubroutine ()
 
 TEST (PassingTest, PassingTest1)
 
 TEST (PassingTest, PassingTest2)
 
 TEST_P (FailingParamTest, Fails)
 
 INSTANTIATE_TEST_CASE_P (PrintingFailingParams, FailingParamTest, testing::Values(2))
 
 TEST (NonfatalFailureTest, EscapesStringOperands)
 
 TEST (NonfatalFailureTest, DiffForLongStrings)
 
 TEST (FatalFailureTest, FatalFailureInSubroutine)
 
 TEST (FatalFailureTest, FatalFailureInNestedSubroutine)
 
 TEST (FatalFailureTest, NonfatalFailureInSubroutine)
 
 TEST (LoggingTest, InterleavingLoggingAndAssertions)
 
void SubWithoutTrace (int n)
 
void SubWithTrace (int n)
 
 TEST (SCOPED_TRACETest, AcceptedValues)
 
 TEST (SCOPED_TRACETest, ObeysScopes)
 
 TEST (SCOPED_TRACETest, WorksInLoop)
 
 TEST (SCOPED_TRACETest, WorksInSubroutine)
 
 TEST (SCOPED_TRACETest, CanBeNested)
 
 TEST (SCOPED_TRACETest, CanBeRepeated)
 
 TEST (ScopedTraceTest, WithExplicitFileAndLine)
 
 TEST (DisabledTestsWarningTest, DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning)
 
void AdHocTest ()
 
int RunAllTests ()
 
 TEST_F (NonFatalFailureInFixtureConstructorTest, FailureInConstructor)
 
 TEST_F (FatalFailureInFixtureConstructorTest, FailureInConstructor)
 
 TEST_F (NonFatalFailureInSetUpTest, FailureInSetUp)
 
 TEST_F (FatalFailureInSetUpTest, FailureInSetUp)
 
 TEST (AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber)
 
 foo::TEST_F (MixedUpTestCaseTest, FirstTestFromNamespaceFoo)
 
 foo::TEST_F (MixedUpTestCaseTest, SecondTestFromNamespaceFoo)
 
 foo::TEST_F (MixedUpTestCaseWithSameTestNameTest, TheSecondTestWithThisNameShouldFail)
 
 bar::TEST_F (MixedUpTestCaseTest, ThisShouldFail)
 
 bar::TEST_F (MixedUpTestCaseTest, ThisShouldFailToo)
 
 bar::TEST_F (MixedUpTestCaseWithSameTestNameTest, TheSecondTestWithThisNameShouldFail)
 
 TEST_F (TEST_F_before_TEST_in_same_test_case, DefinedUsingTEST_F)
 
 TEST (TEST_F_before_TEST_in_same_test_case, DefinedUsingTESTAndShouldFail)
 
 TEST (TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST)
 
 TEST_F (TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST_FAndShouldFail)
 
 TEST (ExpectNonfatalFailureTest, CanReferenceGlobalVariables)
 
 TEST (ExpectNonfatalFailureTest, CanReferenceLocalVariables)
 
 TEST (ExpectNonfatalFailureTest, SucceedsWhenThereIsOneNonfatalFailure)
 
 TEST (ExpectNonfatalFailureTest, FailsWhenThereIsNoNonfatalFailure)
 
 TEST (ExpectNonfatalFailureTest, FailsWhenThereAreTwoNonfatalFailures)
 
 TEST (ExpectNonfatalFailureTest, FailsWhenThereIsOneFatalFailure)
 
 TEST (ExpectNonfatalFailureTest, FailsWhenStatementReturns)
 
 TEST (ExpectFatalFailureTest, CanReferenceGlobalVariables)
 
 TEST (ExpectFatalFailureTest, CanReferenceLocalStaticVariables)
 
 TEST (ExpectFatalFailureTest, SucceedsWhenThereIsOneFatalFailure)
 
 TEST (ExpectFatalFailureTest, FailsWhenThereIsNoFatalFailure)
 
void FatalFailure ()
 
 TEST (ExpectFatalFailureTest, FailsWhenThereAreTwoFatalFailures)
 
 TEST (ExpectFatalFailureTest, FailsWhenThereIsOneNonfatalFailure)
 
 TEST (ExpectFatalFailureTest, FailsWhenStatementReturns)
 
std::string ParamNameFunc (const testing::TestParamInfo< std::string > &info)
 
 TEST_P (ParamTest, Success)
 
 TEST_P (ParamTest, Failure)
 
 INSTANTIATE_TEST_CASE_P (PrintingStrings, ParamTest, testing::Values(std::string("a")), ParamNameFunc)
 
 TEST_F (ExpectFailureTest, ExpectFatalFailure)
 
 TEST_F (ExpectFailureTest, ExpectNonFatalFailure)
 
 TEST_F (ExpectFailureTest, ExpectFatalFailureOnAllThreads)
 
 TEST_F (ExpectFailureTest, ExpectNonFatalFailureOnAllThreads)
 
int main (int argc, char **argv)
 

Variables

int global_integer = 0
 

Function Documentation

◆ AdHocTest()

void AdHocTest ( )

Definition at line 346 of file gtest_output_test_.cc.

346 {
347 printf("The non-test part of the code is expected to have 2 failures.\n\n");
348 EXPECT_TRUE(false);
349 EXPECT_EQ(2, 3);
350}
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
#define EXPECT_TRUE(condition)
Definition gtest.h:1895
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Here is the caller graph for this function:

◆ FatalFailure()

void FatalFailure ( )

Definition at line 719 of file gtest_output_test_.cc.

719 {
720 FAIL() << "Expected fatal failure.";
721}
#define FAIL()
Definition gtest.h:1858
Here is the caller graph for this function:

◆ INSTANTIATE_TEST_CASE_P() [1/2]

INSTANTIATE_TEST_CASE_P ( PrintingFailingParams ,
FailingParamTest ,
testing::Values(2)  )

◆ INSTANTIATE_TEST_CASE_P() [2/2]

INSTANTIATE_TEST_CASE_P ( PrintingStrings ,
ParamTest ,
testing::Values(std::string("a")) ,
ParamNameFunc  )

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1029 of file gtest_output_test_.cc.

1029 {
1030 testing::GTEST_FLAG(print_time) = false;
1031
1032 // We just run the tests, knowing some of them are intended to fail.
1033 // We will use a separate Python script to compare the output of
1034 // this program with the golden file.
1035
1036 // It's hard to test InitGoogleTest() directly, as it has many
1037 // global side effects. The following line serves as a sanity test
1038 // for it.
1040 bool internal_skip_environment_and_ad_hoc_tests =
1041 std::count(argv, argv + argc,
1042 std::string("internal_skip_environment_and_ad_hoc_tests")) > 0;
1043
1044#if GTEST_HAS_DEATH_TEST
1045 if (testing::internal::GTEST_FLAG(internal_run_death_test) != "") {
1046 // Skip the usual output capturing if we're running as the child
1047 // process of an threadsafe-style death test.
1048# if GTEST_OS_WINDOWS
1049 posix::FReopen("nul:", "w", stdout);
1050# else
1051 posix::FReopen("/dev/null", "w", stdout);
1052# endif // GTEST_OS_WINDOWS
1053 return RUN_ALL_TESTS();
1054 }
1055#endif // GTEST_HAS_DEATH_TEST
1056
1057 if (internal_skip_environment_and_ad_hoc_tests)
1058 return RUN_ALL_TESTS();
1059
1060 // Registers two global test environments.
1061 // The golden file verifies that they are set up in the order they
1062 // are registered, and torn down in the reverse order.
1065
1066 return RunAllTests();
1067}
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition gtest.h:2328
int RunAllTests()
char ** argv
FILE * FReopen(const char *path, const char *mode, FILE *stream)
Environment * AddGlobalTestEnvironment(Environment *env)
Definition gtest.h:1391
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition gtest.cc:5787
Here is the call graph for this function:

◆ ParamNameFunc()

std::string ParamNameFunc ( const testing::TestParamInfo< std::string > & info)

Definition at line 769 of file gtest_output_test_.cc.

769 {
770 return info.param;
771}

◆ RunAllTests()

int RunAllTests ( )

Definition at line 353 of file gtest_output_test_.cc.

353 {
354 AdHocTest();
355 return RUN_ALL_TESTS();
356}
void AdHocTest()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SubWithoutTrace()

void SubWithoutTrace ( int n)

Definition at line 159 of file gtest_output_test_.cc.

159 {
160 EXPECT_EQ(1, n);
161 ASSERT_EQ(2, n);
162}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1988
Here is the caller graph for this function:

◆ SubWithTrace()

void SubWithTrace ( int n)

Definition at line 165 of file gtest_output_test_.cc.

165 {
166 SCOPED_TRACE(testing::Message() << "n = " << n);
167
169}
#define SCOPED_TRACE(message)
Definition gtest.h:2202
void SubWithoutTrace(int n)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST() [1/33]

TEST ( AddFailureAtTest ,
MessageContainsSpecifiedFileAndLineNumber  )

Definition at line 470 of file gtest_output_test_.cc.

470 {
471 ADD_FAILURE_AT("foo.cc", 42) << "Expected failure in foo.cc";
472}
#define ADD_FAILURE_AT(file, line)
Definition gtest.h:1848

◆ TEST() [2/33]

TEST ( DisabledTestsWarningTest ,
DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning  )

Definition at line 335 of file gtest_output_test_.cc.

336 {
337 // This test body is intentionally empty. Its sole purpose is for
338 // verifying that the --gtest_also_run_disabled_tests flag
339 // suppresses the "YOU HAVE 12 DISABLED TESTS" warning at the end of
340 // the test output.
341}

◆ TEST() [3/33]

TEST ( ExpectFatalFailureTest ,
CanReferenceGlobalVariables  )

Definition at line 685 of file gtest_output_test_.cc.

685 {
686 global_integer = 0;
688 ASSERT_EQ(1, global_integer) << "Expected fatal failure.";
689 }, "Expected fatal failure.");
690}
#define EXPECT_FATAL_FAILURE(statement, substr)
Definition gtest-spi.h:137
int global_integer

◆ TEST() [4/33]

TEST ( ExpectFatalFailureTest ,
CanReferenceLocalStaticVariables  )

Definition at line 694 of file gtest_output_test_.cc.

694 {
695 static int n;
696 n = 1;
698 ASSERT_EQ(0, n) << "Expected fatal failure.";
699 }, "Expected fatal failure.");
700}

◆ TEST() [5/33]

TEST ( ExpectFatalFailureTest ,
FailsWhenStatementReturns  )

Definition at line 744 of file gtest_output_test_.cc.

744 {
745 printf("(expecting a failure)\n");
747 return;
748 }, "");
749}

◆ TEST() [6/33]

TEST ( ExpectFatalFailureTest ,
FailsWhenThereAreTwoFatalFailures  )

Definition at line 725 of file gtest_output_test_.cc.

725 {
726 printf("(expecting a failure)\n");
728 FatalFailure();
729 FatalFailure();
730 }, "");
731}
void FatalFailure()
Here is the call graph for this function:

◆ TEST() [7/33]

TEST ( ExpectFatalFailureTest ,
FailsWhenThereIsNoFatalFailure  )

Definition at line 712 of file gtest_output_test_.cc.

712 {
713 printf("(expecting a failure)\n");
715 }, "");
716}

◆ TEST() [8/33]

TEST ( ExpectFatalFailureTest ,
FailsWhenThereIsOneNonfatalFailure  )

Definition at line 735 of file gtest_output_test_.cc.

735 {
736 printf("(expecting a failure)\n");
738 ADD_FAILURE() << "Expected non-fatal failure.";
739 }, "");
740}
#define ADD_FAILURE()
Definition gtest.h:1844

◆ TEST() [9/33]

TEST ( ExpectFatalFailureTest ,
SucceedsWhenThereIsOneFatalFailure  )

Definition at line 704 of file gtest_output_test_.cc.

704 {
706 FAIL() << "Expected fatal failure.";
707 }, "Expected fatal failure.");
708}

◆ TEST() [10/33]

TEST ( ExpectNonfatalFailureTest ,
CanReferenceGlobalVariables  )

Definition at line 606 of file gtest_output_test_.cc.

606 {
607 global_integer = 0;
609 EXPECT_EQ(1, global_integer) << "Expected non-fatal failure.";
610 }, "Expected non-fatal failure.");
611}
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Definition gtest-spi.h:203

◆ TEST() [11/33]

TEST ( ExpectNonfatalFailureTest ,
CanReferenceLocalVariables  )

Definition at line 615 of file gtest_output_test_.cc.

615 {
616 int m = 0;
617 static int n;
618 n = 1;
620 EXPECT_EQ(m, n) << "Expected non-fatal failure.";
621 }, "Expected non-fatal failure.");
622}

◆ TEST() [12/33]

TEST ( ExpectNonfatalFailureTest ,
FailsWhenStatementReturns  )

Definition at line 661 of file gtest_output_test_.cc.

661 {
662 printf("(expecting a failure)\n");
664 return;
665 }, "");
666}

◆ TEST() [13/33]

TEST ( ExpectNonfatalFailureTest ,
FailsWhenThereAreTwoNonfatalFailures  )

Definition at line 642 of file gtest_output_test_.cc.

642 {
643 printf("(expecting a failure)\n");
645 ADD_FAILURE() << "Expected non-fatal failure 1.";
646 ADD_FAILURE() << "Expected non-fatal failure 2.";
647 }, "");
648}

◆ TEST() [14/33]

TEST ( ExpectNonfatalFailureTest ,
FailsWhenThereIsNoNonfatalFailure  )

Definition at line 634 of file gtest_output_test_.cc.

634 {
635 printf("(expecting a failure)\n");
637 }, "");
638}

◆ TEST() [15/33]

TEST ( ExpectNonfatalFailureTest ,
FailsWhenThereIsOneFatalFailure  )

Definition at line 652 of file gtest_output_test_.cc.

652 {
653 printf("(expecting a failure)\n");
655 FAIL() << "Expected fatal failure.";
656 }, "");
657}

◆ TEST() [16/33]

TEST ( ExpectNonfatalFailureTest ,
SucceedsWhenThereIsOneNonfatalFailure  )

Definition at line 626 of file gtest_output_test_.cc.

626 {
628 ADD_FAILURE() << "Expected non-fatal failure.";
629 }, "Expected non-fatal failure.");
630}

◆ TEST() [17/33]

TEST ( FatalFailureTest ,
FatalFailureInNestedSubroutine  )

Definition at line 120 of file gtest_output_test_.cc.

120 {
121 printf("(expecting a failure that x should be 1)\n");
122
123 // Calls a subrountine that yields a fatal failure.
125
126 // Catches the fatal failure and aborts the test.
127 //
128 // When calling HasFatalFailure() inside a TEST, TEST_F, or test
129 // fixture, the testing::Test:: prefix is not needed.
130 if (HasFatalFailure()) return;
131
132 // If we get here, something is wrong.
133 FAIL() << "This should never be reached.";
134}
void TryTestSubroutine()
Here is the call graph for this function:

◆ TEST() [18/33]

TEST ( FatalFailureTest ,
FatalFailureInSubroutine  )

Definition at line 113 of file gtest_output_test_.cc.

113 {
114 printf("(expecting a failure that x should be 1)\n");
115
117}
Here is the call graph for this function:

◆ TEST() [19/33]

TEST ( FatalFailureTest ,
NonfatalFailureInSubroutine  )

Definition at line 137 of file gtest_output_test_.cc.

137 {
138 printf("(expecting a failure on false)\n");
139 EXPECT_TRUE(false); // Generates a nonfatal failure
140 ASSERT_FALSE(HasFatalFailure()); // This should succeed.
141}
#define ASSERT_FALSE(condition)
Definition gtest.h:1904

◆ TEST() [20/33]

TEST ( LoggingTest ,
InterleavingLoggingAndAssertions  )

Definition at line 144 of file gtest_output_test_.cc.

144 {
145 static const int a[4] = {
146 3, 9, 2, 6
147 };
148
149 printf("(expecting 2 failures on (3) >= (a[i]))\n");
150 for (int i = 0; i < static_cast<int>(sizeof(a)/sizeof(*a)); i++) {
151 printf("i == %d\n", i);
152 EXPECT_GE(3, a[i]);
153 }
154}
#define EXPECT_GE(val1, val2)
Definition gtest.h:1964
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ TEST() [21/33]

TEST ( NonfatalFailureTest ,
DiffForLongStrings  )

Definition at line 107 of file gtest_output_test_.cc.

107 {
108 std::string golden_str(kGoldenString, sizeof(kGoldenString) - 1);
109 EXPECT_EQ(golden_str, "Line 2");
110}

◆ TEST() [22/33]

TEST ( NonfatalFailureTest ,
EscapesStringOperands  )

Definition at line 99 of file gtest_output_test_.cc.

99 {
100 std::string actual = "actual \"string\"";
101 EXPECT_EQ(kGoldenString, actual);
102
103 const char* golden = kGoldenString;
104 EXPECT_EQ(golden, actual);
105}

◆ TEST() [23/33]

TEST ( PassingTest ,
PassingTest1  )

Definition at line 77 of file gtest_output_test_.cc.

77 {
78}

◆ TEST() [24/33]

TEST ( PassingTest ,
PassingTest2  )

Definition at line 80 of file gtest_output_test_.cc.

80 {
81}

◆ TEST() [25/33]

TEST ( SCOPED_TRACETest ,
AcceptedValues  )

Definition at line 171 of file gtest_output_test_.cc.

171 {
172 SCOPED_TRACE("literal string");
173 SCOPED_TRACE(std::string("std::string"));
174 SCOPED_TRACE(1337); // streamable type
175 const char* null_value = NULL;
176 SCOPED_TRACE(null_value);
177
178 ADD_FAILURE() << "Just checking that all these values work fine.";
179}

◆ TEST() [26/33]

TEST ( SCOPED_TRACETest ,
CanBeNested  )

Definition at line 220 of file gtest_output_test_.cc.

220 {
221 printf("(expected to fail)\n");
222
223 SCOPED_TRACE(""); // A trace without a message.
224
225 SubWithTrace(2);
226}
void SubWithTrace(int n)
Here is the call graph for this function:

◆ TEST() [27/33]

TEST ( SCOPED_TRACETest ,
CanBeRepeated  )

Definition at line 229 of file gtest_output_test_.cc.

229 {
230 printf("(expected to fail)\n");
231
232 SCOPED_TRACE("A");
234 << "This failure is expected, and should contain trace point A.";
235
236 SCOPED_TRACE("B");
238 << "This failure is expected, and should contain trace point A and B.";
239
240 {
241 SCOPED_TRACE("C");
242 ADD_FAILURE() << "This failure is expected, and should "
243 << "contain trace point A, B, and C.";
244 }
245
246 SCOPED_TRACE("D");
247 ADD_FAILURE() << "This failure is expected, and should "
248 << "contain trace point A, B, and D.";
249}

◆ TEST() [28/33]

TEST ( SCOPED_TRACETest ,
ObeysScopes  )

Definition at line 182 of file gtest_output_test_.cc.

182 {
183 printf("(expected to fail)\n");
184
185 // There should be no trace before SCOPED_TRACE() is invoked.
186 ADD_FAILURE() << "This failure is expected, and shouldn't have a trace.";
187
188 {
189 SCOPED_TRACE("Expected trace");
190 // After SCOPED_TRACE(), a failure in the current scope should contain
191 // the trace.
192 ADD_FAILURE() << "This failure is expected, and should have a trace.";
193 }
194
195 // Once the control leaves the scope of the SCOPED_TRACE(), there
196 // should be no trace again.
197 ADD_FAILURE() << "This failure is expected, and shouldn't have a trace.";
198}

◆ TEST() [29/33]

TEST ( SCOPED_TRACETest ,
WorksInLoop  )

Definition at line 201 of file gtest_output_test_.cc.

201 {
202 printf("(expected to fail)\n");
203
204 for (int i = 1; i <= 2; i++) {
205 SCOPED_TRACE(testing::Message() << "i = " << i);
206
208 }
209}
Here is the call graph for this function:

◆ TEST() [30/33]

TEST ( SCOPED_TRACETest ,
WorksInSubroutine  )

Definition at line 212 of file gtest_output_test_.cc.

212 {
213 printf("(expected to fail)\n");
214
215 SubWithTrace(1);
216 SubWithTrace(2);
217}
Here is the call graph for this function:

◆ TEST() [31/33]

TEST ( ScopedTraceTest ,
WithExplicitFileAndLine  )

Definition at line 330 of file gtest_output_test_.cc.

330 {
331 testing::ScopedTrace trace("explicit_file.cc", 123, "expected trace message");
332 ADD_FAILURE() << "Check that the trace is attached to a particular location.";
333}

◆ TEST() [32/33]

TEST ( TEST_before_TEST_F_in_same_test_case ,
DefinedUsingTEST  )

Definition at line 595 of file gtest_output_test_.cc.

595{}

◆ TEST() [33/33]

TEST ( TEST_F_before_TEST_in_same_test_case ,
DefinedUsingTESTAndShouldFail  )

Definition at line 590 of file gtest_output_test_.cc.

590{}

◆ TEST_F() [1/10]

TEST_F ( ExpectFailureTest ,
ExpectFatalFailure  )

Definition at line 897 of file gtest_output_test_.cc.

897 {
898 // Expected fatal failure, but succeeds.
899 printf("(expecting 1 failure)\n");
900 EXPECT_FATAL_FAILURE(SUCCEED(), "Expected fatal failure.");
901 // Expected fatal failure, but got a non-fatal failure.
902 printf("(expecting 1 failure)\n");
903 EXPECT_FATAL_FAILURE(AddFailure(NONFATAL_FAILURE), "Expected non-fatal "
904 "failure.");
905 // Wrong message.
906 printf("(expecting 1 failure)\n");
907 EXPECT_FATAL_FAILURE(AddFailure(FATAL_FAILURE), "Some other fatal failure "
908 "expected.");
909}
#define SUCCEED()
Definition gtest.h:1867

◆ TEST_F() [2/10]

TEST_F ( ExpectFailureTest ,
ExpectFatalFailureOnAllThreads  )

Definition at line 968 of file gtest_output_test_.cc.

968 {
969 // Expected fatal failure, but succeeds.
970 printf("(expecting 1 failure)\n");
971 EXPECT_FATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), "Expected fatal failure.");
972 // Expected fatal failure, but got a non-fatal failure.
973 printf("(expecting 1 failure)\n");
974 EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),
975 "Expected non-fatal failure.");
976 // Wrong message.
977 printf("(expecting 1 failure)\n");
978 EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),
979 "Some other fatal failure expected.");
980}
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr)
Definition gtest-spi.h:154

◆ TEST_F() [3/10]

TEST_F ( ExpectFailureTest ,
ExpectNonFatalFailure  )

Definition at line 911 of file gtest_output_test_.cc.

911 {
912 // Expected non-fatal failure, but succeeds.
913 printf("(expecting 1 failure)\n");
914 EXPECT_NONFATAL_FAILURE(SUCCEED(), "Expected non-fatal failure.");
915 // Expected non-fatal failure, but got a fatal failure.
916 printf("(expecting 1 failure)\n");
917 EXPECT_NONFATAL_FAILURE(AddFailure(FATAL_FAILURE), "Expected fatal failure.");
918 // Wrong message.
919 printf("(expecting 1 failure)\n");
920 EXPECT_NONFATAL_FAILURE(AddFailure(NONFATAL_FAILURE), "Some other non-fatal "
921 "failure.");
922}

◆ TEST_F() [4/10]

TEST_F ( ExpectFailureTest ,
ExpectNonFatalFailureOnAllThreads  )

Definition at line 982 of file gtest_output_test_.cc.

982 {
983 // Expected non-fatal failure, but succeeds.
984 printf("(expecting 1 failure)\n");
985 EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), "Expected non-fatal "
986 "failure.");
987 // Expected non-fatal failure, but got a fatal failure.
988 printf("(expecting 1 failure)\n");
989 EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),
990 "Expected fatal failure.");
991 // Wrong message.
992 printf("(expecting 1 failure)\n");
993 EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),
994 "Some other non-fatal failure.");
995}
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr)
Definition gtest-spi.h:217

◆ TEST_F() [5/10]

TEST_F ( FatalFailureInFixtureConstructorTest ,
FailureInConstructor  )

Definition at line 413 of file gtest_output_test_.cc.

413 {
414 ADD_FAILURE() << "UNEXPECTED failure in the test body. "
415 << "We should never get here, as the test fixture c'tor "
416 << "had a fatal failure.";
417}

◆ TEST_F() [6/10]

TEST_F ( FatalFailureInSetUpTest ,
FailureInSetUp  )

Definition at line 465 of file gtest_output_test_.cc.

465 {
466 FAIL() << "UNEXPECTED failure in the test function. "
467 << "We should never get here, as SetUp() failed.";
468}

◆ TEST_F() [7/10]

TEST_F ( NonFatalFailureInFixtureConstructorTest ,
FailureInConstructor  )

Definition at line 379 of file gtest_output_test_.cc.

379 {
380 ADD_FAILURE() << "Expected failure #3, in the test body.";
381}

◆ TEST_F() [8/10]

TEST_F ( NonFatalFailureInSetUpTest ,
FailureInSetUp  )

Definition at line 440 of file gtest_output_test_.cc.

440 {
441 FAIL() << "Expected failure #2, in the test function.";
442}

◆ TEST_F() [9/10]

TEST_F ( TEST_before_TEST_F_in_same_test_case ,
DefinedUsingTEST_FAndShouldFail  )

Definition at line 599 of file gtest_output_test_.cc.

599 {
600}

◆ TEST_F() [10/10]

TEST_F ( TEST_F_before_TEST_in_same_test_case ,
DefinedUsingTEST_F  )

Definition at line 586 of file gtest_output_test_.cc.

586{}

◆ TEST_P() [1/3]

TEST_P ( FailingParamTest ,
Fails  )

Definition at line 87 of file gtest_output_test_.cc.

87 {
88 EXPECT_EQ(1, GetParam());
89}

◆ TEST_P() [2/3]

TEST_P ( ParamTest ,
Failure  )

Definition at line 780 of file gtest_output_test_.cc.

780 {
781 EXPECT_EQ("b", GetParam()) << "Expected failure";
782}

◆ TEST_P() [3/3]

TEST_P ( ParamTest ,
Success  )

Definition at line 776 of file gtest_output_test_.cc.

776 {
777 EXPECT_EQ("a", GetParam());
778}

◆ TestEq1()

void TestEq1 ( int x)

Definition at line 57 of file gtest_output_test_.cc.

57 {
58 ASSERT_EQ(1, x);
59}
Here is the caller graph for this function:

◆ TryTestSubroutine()

void TryTestSubroutine ( )

Definition at line 63 of file gtest_output_test_.cc.

63 {
64 // Calls a subrountine that yields a fatal failure.
65 TestEq1(2);
66
67 // Catches the fatal failure and aborts the test.
68 //
69 // The testing::Test:: prefix is necessary when calling
70 // HasFatalFailure() outside of a TEST, TEST_F, or test fixture.
72
73 // If we get here, something is wrong.
74 FAIL() << "This should never be reached.";
75}
static bool HasFatalFailure()
Definition gtest.cc:2505
void TestEq1(int x)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ global_integer

int global_integer = 0

Definition at line 603 of file gtest_output_test_.cc.