34 #include "gtest/gtest-death-test.h" 35 #include "gtest/gtest.h" 36 #include "gtest/internal/gtest-filepath.h" 41 #if GTEST_HAS_DEATH_TEST 47 # include <sys/wait.h> 48 # endif // GTEST_OS_WINDOWS 55 # include <sys/time.h> 56 # endif // GTEST_OS_LINUX 58 # include "gtest/gtest-spi.h" 65 # define GTEST_IMPLEMENTATION_ 1 66 # include "src/gtest-internal-inl.h" 67 # undef GTEST_IMPLEMENTATION_ 69 namespace posix = ::testing::internal::posix;
72 using testing::internal::DeathTest;
73 using testing::internal::DeathTestFactory;
75 using testing::internal::GetLastErrnoDescription;
77 using testing::internal::InDeathTestChild;
78 using testing::internal::ParseNaturalNumber;
85 class ReplaceDeathTestFactory {
87 explicit ReplaceDeathTestFactory(DeathTestFactory* new_factory)
89 old_factory_ = unit_test_impl_->death_test_factory_.release();
90 unit_test_impl_->death_test_factory_.reset(new_factory);
93 ~ReplaceDeathTestFactory() {
94 unit_test_impl_->death_test_factory_.release();
95 unit_test_impl_->death_test_factory_.reset(old_factory_);
99 ReplaceDeathTestFactory(
const ReplaceDeathTestFactory&);
100 void operator=(
const ReplaceDeathTestFactory&);
102 UnitTestImpl* unit_test_impl_;
103 DeathTestFactory* old_factory_;
110 fprintf(stderr,
"%s", message.c_str());
126 DieWithMessage(
"death inside " +
function +
"().");
133 TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {}
135 virtual ~TestForDeathTest() {
140 static void StaticMemberFunction() { DieInside(
"StaticMemberFunction"); }
143 void MemberFunction() {
145 DieInside(
"MemberFunction");
150 const FilePath original_dir_;
156 explicit MayDie(
bool should_die) : should_die_(should_die) {}
159 void MemberFunction()
const {
161 DieInside(
"MayDie::MemberFunction");
170 void GlobalFunction() { DieInside(
"GlobalFunction"); }
173 int NonVoidFunction() {
174 DieInside(
"NonVoidFunction");
179 void DieIf(
bool should_die) {
185 bool DieIfLessThan(
int x,
int y) {
187 DieInside(
"DieIfLessThan");
193 void DeathTestSubroutine() {
194 EXPECT_DEATH(GlobalFunction(),
"death.*GlobalFunction");
195 ASSERT_DEATH(GlobalFunction(),
"death.*GlobalFunction");
199 int DieInDebugElse12(
int* sideeffect) {
200 if (sideeffect) *sideeffect = 12;
204 DieInside(
"DieInDebugElse12");
211 # if GTEST_OS_WINDOWS 214 TEST(ExitStatusPredicateTest, ExitedWithCode) {
229 static int NormalExitStatus(
int exit_code) {
230 pid_t child_pid = fork();
231 if (child_pid == 0) {
235 waitpid(child_pid, &status, 0);
244 static int KilledExitStatus(
int signum) {
245 pid_t child_pid = fork();
246 if (child_pid == 0) {
251 waitpid(child_pid, &status, 0);
256 TEST(ExitStatusPredicateTest, ExitedWithCode) {
257 const int status0 = NormalExitStatus(0);
258 const int status1 = NormalExitStatus(1);
259 const int status42 = NormalExitStatus(42);
260 const testing::ExitedWithCode pred0(0);
261 const testing::ExitedWithCode pred1(1);
262 const testing::ExitedWithCode pred42(42);
272 TEST(ExitStatusPredicateTest, KilledBySignal) {
273 const int status_segv = KilledExitStatus(SIGSEGV);
274 const int status_kill = KilledExitStatus(SIGKILL);
275 const testing::KilledBySignal pred_segv(SIGSEGV);
276 const testing::KilledBySignal pred_kill(SIGKILL);
283 # endif // GTEST_OS_WINDOWS 288 TEST_F(TestForDeathTest, SingleStatement) {
291 ASSERT_DEATH(
return,
"");
294 EXPECT_DEATH(_exit(1),
"");
301 ASSERT_DEATH(
return,
"") <<
"did not die";
306 EXPECT_DEATH(_exit(1),
"") << 1 << 2 << 3;
309 void DieWithEmbeddedNul() {
310 fprintf(stderr,
"Hello%cmy null world.\n",
'\0');
318 TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
321 EXPECT_DEATH(DieWithEmbeddedNul(),
"my null world");
322 ASSERT_DEATH(DieWithEmbeddedNul(),
"my null world");
324 # endif // GTEST_USES_PCRE 328 TEST_F(TestForDeathTest, SwitchStatement) {
332 # pragma warning(push) 333 # pragma warning(disable: 4065) 338 ASSERT_DEATH(_exit(1),
"") <<
"exit in default switch handler";
342 EXPECT_DEATH(_exit(1),
"") <<
"exit in switch case";
345 # pragma warning(pop) 351 TEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {
353 ASSERT_DEATH(StaticMemberFunction(),
"death.*StaticMember");
358 TEST_F(TestForDeathTest, MemberFunctionFastStyle) {
361 EXPECT_DEATH(MemberFunction(),
"inside.*MemberFunction");
368 TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
372 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
375 ASSERT_DEATH(_exit(1),
"");
379 void SigprofAction(
int, siginfo_t*,
void*) { }
382 void SetSigprofActionAndTimer() {
383 struct itimerval timer;
384 timer.it_interval.tv_sec = 0;
385 timer.it_interval.tv_usec = 1;
386 timer.it_value = timer.it_interval;
387 ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));
388 struct sigaction signal_action;
389 memset(&signal_action, 0,
sizeof(signal_action));
390 sigemptyset(&signal_action.sa_mask);
391 signal_action.sa_sigaction = SigprofAction;
392 signal_action.sa_flags = SA_RESTART | SA_SIGINFO;
393 ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, NULL));
397 void DisableSigprofActionAndTimer(
struct sigaction* old_signal_action) {
398 struct itimerval timer;
399 timer.it_interval.tv_sec = 0;
400 timer.it_interval.tv_usec = 0;
401 timer.it_value = timer.it_interval;
402 ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));
403 struct sigaction signal_action;
404 memset(&signal_action, 0,
sizeof(signal_action));
405 sigemptyset(&signal_action.sa_mask);
406 signal_action.sa_handler = SIG_IGN;
407 ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, old_signal_action));
411 TEST_F(TestForDeathTest, FastSigprofActionSet) {
413 SetSigprofActionAndTimer();
414 EXPECT_DEATH(_exit(1),
"");
415 struct sigaction old_signal_action;
416 DisableSigprofActionAndTimer(&old_signal_action);
417 EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
420 TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
422 SetSigprofActionAndTimer();
423 EXPECT_DEATH(_exit(1),
"");
424 struct sigaction old_signal_action;
425 DisableSigprofActionAndTimer(&old_signal_action);
426 EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
428 # endif // GTEST_OS_LINUX 432 TEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {
434 ASSERT_DEATH(StaticMemberFunction(),
"death.*StaticMember");
437 TEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {
440 EXPECT_DEATH(MemberFunction(),
"inside.*MemberFunction");
443 TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
446 for (
int i = 0; i < 3; ++i)
447 EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i),
"") <<
": i = " << i;
450 TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
454 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
457 ASSERT_DEATH(_exit(1),
"");
460 TEST_F(TestForDeathTest, MixedStyles) {
462 EXPECT_DEATH(_exit(1),
"");
464 EXPECT_DEATH(_exit(1),
"");
467 # if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD 473 void SetPthreadFlag() {
479 TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
482 pthread_flag =
false;
483 ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL));
484 ASSERT_DEATH(_exit(1),
"");
489 # endif // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD 492 TEST_F(TestForDeathTest, MethodOfAnotherClass) {
493 const MayDie x(
true);
494 ASSERT_DEATH(x.MemberFunction(),
"MayDie\\:\\:MemberFunction");
498 TEST_F(TestForDeathTest, GlobalFunction) {
499 EXPECT_DEATH(GlobalFunction(),
"GlobalFunction");
504 TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
505 static const char regex_c_str[] =
"GlobalFunction";
506 EXPECT_DEATH(GlobalFunction(), regex_c_str);
509 EXPECT_DEATH(GlobalFunction(), regex);
511 # if GTEST_HAS_GLOBAL_STRING 513 const string regex_str(regex_c_str);
514 EXPECT_DEATH(GlobalFunction(), regex_str);
516 # endif // GTEST_HAS_GLOBAL_STRING 519 EXPECT_DEATH(GlobalFunction(), regex_std_str);
523 TEST_F(TestForDeathTest, NonVoidFunction) {
524 ASSERT_DEATH(NonVoidFunction(),
"NonVoidFunction");
528 TEST_F(TestForDeathTest, FunctionWithParameter) {
529 EXPECT_DEATH(DieIf(
true),
"DieIf\\(\\)");
530 EXPECT_DEATH(DieIfLessThan(2, 3),
"DieIfLessThan");
534 TEST_F(TestForDeathTest, OutsideFixture) {
535 DeathTestSubroutine();
539 TEST_F(TestForDeathTest, InsideLoop) {
540 for (
int i = 0; i < 5; i++) {
541 EXPECT_DEATH(DieIfLessThan(-1, i),
"DieIfLessThan") <<
"where i == " << i;
546 TEST_F(TestForDeathTest, CompoundStatement) {
556 TEST_F(TestForDeathTest, DoesNotDie) {
562 TEST_F(TestForDeathTest, ErrorMessageMismatch) {
564 EXPECT_DEATH(DieIf(
true),
"DieIfLessThan") <<
"End of death test message.";
565 },
"died but not with expected error");
570 void ExpectDeathTestHelper(
bool* aborted) {
572 EXPECT_DEATH(DieIf(
false),
"DieIf");
577 TEST_F(TestForDeathTest, EXPECT_DEATH) {
585 TEST_F(TestForDeathTest, ASSERT_DEATH) {
589 ASSERT_DEATH(DieIf(
false),
"DieIf");
596 TEST_F(TestForDeathTest, SingleEvaluation) {
598 EXPECT_DEATH(DieIf((++x) == 4),
"DieIf");
600 const char* regex =
"DieIf";
601 const char* regex_save = regex;
602 EXPECT_DEATH(DieIfLessThan(3, 4), regex++);
607 TEST_F(TestForDeathTest, RunawayIsFailure) {
614 TEST_F(TestForDeathTest, ReturnIsFailure) {
616 "illegal return in test statement.");
626 TEST_F(TestForDeathTest, TestExpectDebugDeath) {
629 EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect),
"death.*DieInDebugElse12")
630 <<
"Must accept a streamed message";
652 TEST_F(TestForDeathTest, TestAssertDebugDeath) {
655 ASSERT_DEBUG_DEATH(DieInDebugElse12(&sideeffect),
"death.*DieInDebugElse12")
656 <<
"Must accept a streamed message";
673 void ExpectDebugDeathHelper(
bool* aborted) {
675 EXPECT_DEBUG_DEATH(
return,
"") <<
"This is expected to fail.";
679 # if GTEST_OS_WINDOWS 680 TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
681 printf(
"This test should be considered failing if it shows " 682 "any pop-up dialogs.\n");
690 # endif // GTEST_OS_WINDOWS 694 TEST_F(TestForDeathTest, ExpectDebugDeathDoesNotAbort) {
700 void AssertDebugDeathHelper(
bool* aborted) {
702 ASSERT_DEBUG_DEATH(
return,
"") <<
"This is expected to fail.";
708 TEST_F(TestForDeathTest, AssertDebugDeathAborts) {
718 static void TestExitMacros() {
719 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
720 ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42),
"");
722 # if GTEST_OS_WINDOWS 727 EXPECT_EXIT(
raise(SIGABRT), testing::ExitedWithCode(3),
"") <<
"b_ar";
731 EXPECT_EXIT(
raise(SIGKILL), testing::KilledBySignal(SIGKILL),
"") <<
"foo";
732 ASSERT_EXIT(
raise(SIGUSR2), testing::KilledBySignal(SIGUSR2),
"") <<
"bar";
735 ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV),
"")
736 <<
"This failure is expected, too.";
737 },
"This failure is expected, too.");
739 # endif // GTEST_OS_WINDOWS 742 EXPECT_EXIT(
raise(SIGSEGV), testing::ExitedWithCode(0),
"")
743 <<
"This failure is expected.";
744 },
"This failure is expected.");
747 TEST_F(TestForDeathTest, ExitMacros) {
751 TEST_F(TestForDeathTest, ExitMacrosUsingFork) {
756 TEST_F(TestForDeathTest, InvalidStyle) {
759 EXPECT_DEATH(_exit(0),
"") <<
"This failure is expected.";
760 },
"This failure is expected.");
763 TEST_F(TestForDeathTest, DeathTestFailedOutput) {
766 EXPECT_DEATH(DieWithMessage(
"death\n"),
769 "[ DEATH ] death\n");
772 TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
776 fprintf(stderr,
"returning\n");
780 " Result: illegal return in test statement.\n" 782 "[ DEATH ] returning\n");
785 TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
788 EXPECT_EXIT(DieWithMessage(
"exiting with rc 1\n"),
789 testing::ExitedWithCode(3),
791 " Result: died but not with expected exit code:\n" 792 " Exited with exit status 1\n" 794 "[ DEATH ] exiting with rc 1\n");
797 TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
800 EXPECT_DEATH(DieWithMessage(
"line 1\nline 2\nline 3\n"),
801 "line 1\nxyz\nline 3\n"),
805 "[ DEATH ] line 3\n");
808 TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
810 EXPECT_DEATH(DieWithMessage(
"line 1\nline 2\nline 3\n"),
811 "line 1\nline 2\nline 3\n");
815 class MockDeathTestFactory :
public DeathTestFactory {
817 MockDeathTestFactory();
818 virtual bool Create(
const char* statement,
819 const ::testing::internal::RE* regex,
820 const char* file,
int line, DeathTest**
test);
823 void SetParameters(
bool create, DeathTest::TestRole role,
824 int status,
bool passed);
827 int AssumeRoleCalls()
const {
return assume_role_calls_; }
828 int WaitCalls()
const {
return wait_calls_; }
829 int PassedCalls()
const {
return passed_args_.size(); }
830 bool PassedArgument(
int n)
const {
return passed_args_[n]; }
831 int AbortCalls()
const {
return abort_args_.size(); }
832 DeathTest::AbortReason AbortArgument(
int n)
const {
833 return abort_args_[n];
835 bool TestDeleted()
const {
return test_deleted_; }
838 friend class MockDeathTest;
843 DeathTest::TestRole role_;
850 int assume_role_calls_;
855 std::vector<bool> passed_args_;
858 std::vector<DeathTest::AbortReason> abort_args_;
869 class MockDeathTest :
public DeathTest {
871 MockDeathTest(MockDeathTestFactory *parent,
872 TestRole role,
int status,
bool passed) :
873 parent_(parent), role_(role), status_(status), passed_(passed) {
875 virtual ~MockDeathTest() {
876 parent_->test_deleted_ =
true;
878 virtual TestRole AssumeRole() {
879 ++parent_->assume_role_calls_;
883 ++parent_->wait_calls_;
886 virtual bool Passed(
bool exit_status_ok) {
887 parent_->passed_args_.push_back(exit_status_ok);
890 virtual void Abort(AbortReason reason) {
891 parent_->abort_args_.push_back(reason);
895 MockDeathTestFactory*
const parent_;
896 const TestRole role_;
903 MockDeathTestFactory::MockDeathTestFactory()
905 role_(DeathTest::OVERSEE_TEST),
908 assume_role_calls_(0),
916 void MockDeathTestFactory::SetParameters(
bool create,
917 DeathTest::TestRole role,
918 int status,
bool passed) {
924 assume_role_calls_ = 0;
926 passed_args_.clear();
934 bool MockDeathTestFactory::Create(
const char* ,
935 const ::testing::internal::RE* ,
939 test_deleted_ =
false;
941 *test =
new MockDeathTest(
this, role_, status_, passed_);
953 static testing::internal::ReplaceDeathTestFactory* replacer_;
954 static MockDeathTestFactory* factory_;
957 factory_ =
new MockDeathTestFactory;
958 replacer_ =
new testing::internal::ReplaceDeathTestFactory(factory_);
971 static void RunReturningDeathTest(
bool* flag) {
979 testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_
981 MockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL;
985 TEST_F(MacroLogicDeathTest, NothingHappens) {
987 factory_->SetParameters(
false, DeathTest::OVERSEE_TEST, 0,
true);
988 EXPECT_DEATH(flag =
true,
"");
990 EXPECT_EQ(0, factory_->AssumeRoleCalls());
1000 TEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) {
1002 factory_->SetParameters(
true, DeathTest::OVERSEE_TEST, 0,
true);
1003 EXPECT_DEATH(flag =
true,
"");
1005 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1015 TEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) {
1017 factory_->SetParameters(
true, DeathTest::OVERSEE_TEST, 1,
true);
1018 EXPECT_DEATH(flag =
true,
"");
1020 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1031 TEST_F(MacroLogicDeathTest, ChildPerformsReturn) {
1033 factory_->SetParameters(
true, DeathTest::EXECUTE_TEST, 0,
true);
1034 RunReturningDeathTest(&flag);
1036 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1040 EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1041 factory_->AbortArgument(0));
1047 TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
1049 factory_->SetParameters(
true, DeathTest::EXECUTE_TEST, 0,
true);
1050 EXPECT_DEATH(flag =
true,
"");
1052 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1062 factory_->AbortArgument(0));
1063 EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1064 factory_->AbortArgument(1));
1070 TEST(SuccessRegistrationDeathTest, NoSuccessPart) {
1071 EXPECT_DEATH(_exit(1),
"");
1075 TEST(StreamingAssertionsDeathTest, DeathTest) {
1076 EXPECT_DEATH(_exit(1),
"") <<
"unexpected failure";
1077 ASSERT_DEATH(_exit(1),
"") <<
"unexpected failure";
1079 EXPECT_DEATH(_exit(0),
"") <<
"expected failure";
1080 },
"expected failure");
1082 ASSERT_DEATH(_exit(0),
"") <<
"expected failure";
1083 },
"expected failure");
1088 TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
1095 # if GTEST_OS_WINDOWS 1096 TEST(AutoHandleTest, AutoHandleWorks) {
1097 HANDLE
handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
1098 ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1101 testing::internal::AutoHandle auto_handle(handle);
1106 auto_handle.Reset();
1107 EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle.Get());
1111 handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
1112 ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1113 auto_handle.Reset(handle);
1117 testing::internal::AutoHandle auto_handle2;
1118 EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());
1120 # endif // GTEST_OS_WINDOWS 1122 # if GTEST_OS_WINDOWS 1123 typedef unsigned __int64 BiggestParsable;
1124 typedef signed __int64 BiggestSignedParsable;
1126 typedef unsigned long long BiggestParsable;
1127 typedef signed long long BiggestSignedParsable;
1128 # endif // GTEST_OS_WINDOWS 1132 const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
1133 const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
1135 TEST(ParseNaturalNumberTest, RejectsInvalidFormat) {
1136 BiggestParsable result = 0;
1139 EXPECT_FALSE(ParseNaturalNumber(
"non-number string", &result));
1152 TEST(ParseNaturalNumberTest, RejectsOverflownNumbers) {
1153 BiggestParsable result = 0;
1155 EXPECT_FALSE(ParseNaturalNumber(
"99999999999999999999999", &result));
1157 signed char char_result = 0;
1162 TEST(ParseNaturalNumberTest, AcceptsValidNumbers) {
1163 BiggestParsable result = 0;
1175 ASSERT_TRUE(ParseNaturalNumber(
"00000", &result));
1179 TEST(ParseNaturalNumberTest, AcceptsTypeLimits) {
1181 msg << kBiggestParsableMax;
1183 BiggestParsable result = 0;
1184 EXPECT_TRUE(ParseNaturalNumber(msg.GetString(), &result));
1188 msg2 << kBiggestSignedParsableMax;
1190 BiggestSignedParsable signed_result = 0;
1191 EXPECT_TRUE(ParseNaturalNumber(msg2.GetString(), &signed_result));
1192 EXPECT_EQ(kBiggestSignedParsableMax, signed_result);
1198 EXPECT_TRUE(ParseNaturalNumber(msg3.GetString(), &int_result));
1204 unsigned int uint_result = 0;
1205 EXPECT_TRUE(ParseNaturalNumber(msg4.GetString(), &uint_result));
1209 TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
1210 short short_result = 0;
1211 ASSERT_TRUE(ParseNaturalNumber(
"123", &short_result));
1214 signed char char_result = 0;
1215 ASSERT_TRUE(ParseNaturalNumber(
"123", &char_result));
1219 # if GTEST_OS_WINDOWS 1220 TEST(EnvironmentTest, HandleFitsIntoSizeT) {
1226 # endif // GTEST_OS_WINDOWS 1230 TEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {
1232 "death inside CondDeathTestExpectMacro");
1234 "death inside CondDeathTestAssertMacro");
1249 TEST(ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable) {
1256 "Death tests are not supported on this platform"));
1263 ASSERT_TRUE(NULL == strstr(output.c_str(),
"streamed message"));
1269 "Death tests are not supported on this platform"));
1275 ASSERT_TRUE(NULL == strstr(output.c_str(),
"streamed message"));
1285 TEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {
1291 TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
1295 fprintf(stderr, InDeathTestChild() ?
"Inside" :
"Outside");
1301 TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
1305 fprintf(stderr, InDeathTestChild() ?
"Inside" :
"Outside");
1311 #endif // GTEST_HAS_DEATH_TEST 1318 TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
1341 TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
1345 # pragma warning(push) 1346 # pragma warning(disable: 4065) 1352 <<
"exit in default switch handler";
1359 # pragma warning(pop)
UnitTestImpl * GetUnitTestImpl()
std::string GetCapturedStderr()
static void SetUpTestCase()
#define EXPECT_FATAL_FAILURE(statement, substr)
#define EXPECT_NONFATAL_FAILURE(statement, substr)
TEST_F(TestInfoTest, Names)
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex)
int ChDir(const char *dir)
#define EXPECT_TRUE(condition)
#define EXPECT_STREQ(expected, actual)
#define EXPECT_PRED1(pred, v1)
#define ASSERT_NE(val1, val2)
TEST_F(ListenerTest, DoesFoo)
std::shared_ptr< logger > create(const std::string &logger_name, const sink_ptr &sink)
#define EXPECT_FALSE(condition)
TEST(GTestEnvVarTest, Dummy)
#define ASSERT_TRUE(condition)
#define ASSERT_EQ(val1, val2)
#define EXPECT_STRNE(s1, s2)
void FuncWithAssert(int *n)
FMT_API int fprintf(std::FILE *f, CStringRef format, ArgList args)
#define EXPECT_EQ(expected, actual)
static void TearDownTestCase()
#define ASSERT_FALSE(condition)
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
TEST(IsXDigitTest, WorksForNarrowAscii)
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)