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 65 # define GTEST_IMPLEMENTATION_ 1 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) {
335 ASSERT_DEATH(_exit(1), "") << "exit in default switch handler";
339 EXPECT_DEATH(_exit(1), "") << "exit in switch case";
346 TEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {
348 ASSERT_DEATH(StaticMemberFunction(),
"death.*StaticMember");
353 TEST_F(TestForDeathTest, MemberFunctionFastStyle) {
356 EXPECT_DEATH(MemberFunction(),
"inside.*MemberFunction");
363 TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
367 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
370 ASSERT_DEATH(_exit(1),
"");
374 void SigprofAction(
int, siginfo_t*,
void*) { }
377 void SetSigprofActionAndTimer() {
378 struct itimerval
timer;
379 timer.it_interval.tv_sec = 0;
380 timer.it_interval.tv_usec = 1;
383 struct sigaction signal_action;
384 memset(&signal_action, 0,
sizeof(signal_action));
385 sigemptyset(&signal_action.sa_mask);
386 signal_action.sa_sigaction = SigprofAction;
387 signal_action.sa_flags = SA_RESTART | SA_SIGINFO;
388 ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, NULL));
392 void DisableSigprofActionAndTimer(
struct sigaction* old_signal_action) {
393 struct itimerval
timer;
394 timer.it_interval.tv_sec = 0;
395 timer.it_interval.tv_usec = 0;
398 struct sigaction signal_action;
399 memset(&signal_action, 0,
sizeof(signal_action));
400 sigemptyset(&signal_action.sa_mask);
401 signal_action.sa_handler = SIG_IGN;
402 ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, old_signal_action));
406 TEST_F(TestForDeathTest, FastSigprofActionSet) {
408 SetSigprofActionAndTimer();
409 EXPECT_DEATH(_exit(1),
"");
410 struct sigaction old_signal_action;
411 DisableSigprofActionAndTimer(&old_signal_action);
412 EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
415 TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
417 SetSigprofActionAndTimer();
418 EXPECT_DEATH(_exit(1),
"");
419 struct sigaction old_signal_action;
420 DisableSigprofActionAndTimer(&old_signal_action);
421 EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
423 # endif // GTEST_OS_LINUX 427 TEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {
429 ASSERT_DEATH(StaticMemberFunction(),
"death.*StaticMember");
432 TEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {
435 EXPECT_DEATH(MemberFunction(),
"inside.*MemberFunction");
438 TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
441 for (
int i = 0;
i < 3; ++
i)
442 EXPECT_EXIT(_exit(
i), testing::ExitedWithCode(
i),
"") <<
": i = " <<
i;
445 TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
449 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
452 ASSERT_DEATH(_exit(1),
"");
455 TEST_F(TestForDeathTest, MixedStyles) {
457 EXPECT_DEATH(_exit(1),
"");
459 EXPECT_DEATH(_exit(1),
"");
462 # if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD 468 void SetPthreadFlag() {
474 TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
477 pthread_flag =
false;
478 ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL));
479 ASSERT_DEATH(_exit(1),
"");
484 # endif // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD 487 TEST_F(TestForDeathTest, MethodOfAnotherClass) {
488 const MayDie x(
true);
489 ASSERT_DEATH(x.MemberFunction(),
"MayDie\\:\\:MemberFunction");
493 TEST_F(TestForDeathTest, GlobalFunction) {
494 EXPECT_DEATH(GlobalFunction(),
"GlobalFunction");
499 TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
500 static const char regex_c_str[] =
"GlobalFunction";
501 EXPECT_DEATH(GlobalFunction(), regex_c_str);
504 EXPECT_DEATH(GlobalFunction(), regex);
506 # if GTEST_HAS_GLOBAL_STRING 508 const string regex_str(regex_c_str);
509 EXPECT_DEATH(GlobalFunction(), regex_str);
511 # endif // GTEST_HAS_GLOBAL_STRING 514 EXPECT_DEATH(GlobalFunction(), regex_std_str);
518 TEST_F(TestForDeathTest, NonVoidFunction) {
519 ASSERT_DEATH(NonVoidFunction(),
"NonVoidFunction");
523 TEST_F(TestForDeathTest, FunctionWithParameter) {
524 EXPECT_DEATH(DieIf(
true),
"DieIf\\(\\)");
525 EXPECT_DEATH(DieIfLessThan(2, 3),
"DieIfLessThan");
529 TEST_F(TestForDeathTest, OutsideFixture) {
530 DeathTestSubroutine();
534 TEST_F(TestForDeathTest, InsideLoop) {
535 for (
int i = 0;
i < 5;
i++) {
536 EXPECT_DEATH(DieIfLessThan(-1,
i),
"DieIfLessThan") <<
"where i == " <<
i;
541 TEST_F(TestForDeathTest, CompoundStatement) {
551 TEST_F(TestForDeathTest, DoesNotDie) {
557 TEST_F(TestForDeathTest, ErrorMessageMismatch) {
559 EXPECT_DEATH(DieIf(
true),
"DieIfLessThan") <<
"End of death test message.";
560 },
"died but not with expected error");
565 void ExpectDeathTestHelper(
bool* aborted) {
567 EXPECT_DEATH(DieIf(
false),
"DieIf");
572 TEST_F(TestForDeathTest, EXPECT_DEATH) {
580 TEST_F(TestForDeathTest, ASSERT_DEATH) {
584 ASSERT_DEATH(DieIf(
false),
"DieIf");
591 TEST_F(TestForDeathTest, SingleEvaluation) {
593 EXPECT_DEATH(DieIf((++x) == 4),
"DieIf");
595 const char* regex =
"DieIf";
596 const char* regex_save = regex;
597 EXPECT_DEATH(DieIfLessThan(3, 4), regex++);
602 TEST_F(TestForDeathTest, RunawayIsFailure) {
609 TEST_F(TestForDeathTest, ReturnIsFailure) {
611 "illegal return in test statement.");
621 TEST_F(TestForDeathTest, TestExpectDebugDeath) {
624 EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect),
"death.*DieInDebugElse12")
625 <<
"Must accept a streamed message";
647 TEST_F(TestForDeathTest, TestAssertDebugDeath) {
650 ASSERT_DEBUG_DEATH(DieInDebugElse12(&sideeffect),
"death.*DieInDebugElse12")
651 <<
"Must accept a streamed message";
668 void ExpectDebugDeathHelper(
bool* aborted) {
670 EXPECT_DEBUG_DEATH(
return,
"") <<
"This is expected to fail.";
674 # if GTEST_OS_WINDOWS 675 TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
676 printf(
"This test should be considered failing if it shows " 677 "any pop-up dialogs.\n");
685 # endif // GTEST_OS_WINDOWS 689 TEST_F(TestForDeathTest, ExpectDebugDeathDoesNotAbort) {
695 void AssertDebugDeathHelper(
bool* aborted) {
697 GTEST_LOG_(INFO) <<
"Before ASSERT_DEBUG_DEATH";
698 ASSERT_DEBUG_DEATH(
GTEST_LOG_(INFO) <<
"In ASSERT_DEBUG_DEATH";
return,
"")
699 <<
"This is expected to fail.";
700 GTEST_LOG_(INFO) <<
"After ASSERT_DEBUG_DEATH";
706 TEST_F(TestForDeathTest, AssertDebugDeathAborts) {
713 TEST_F(TestForDeathTest, AssertDebugDeathAborts2) {
720 TEST_F(TestForDeathTest, AssertDebugDeathAborts3) {
727 TEST_F(TestForDeathTest, AssertDebugDeathAborts4) {
734 TEST_F(TestForDeathTest, AssertDebugDeathAborts5) {
741 TEST_F(TestForDeathTest, AssertDebugDeathAborts6) {
748 TEST_F(TestForDeathTest, AssertDebugDeathAborts7) {
755 TEST_F(TestForDeathTest, AssertDebugDeathAborts8) {
762 TEST_F(TestForDeathTest, AssertDebugDeathAborts9) {
769 TEST_F(TestForDeathTest, AssertDebugDeathAborts10) {
779 static void TestExitMacros() {
780 EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1),
"");
781 ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42),
"");
783 # if GTEST_OS_WINDOWS 788 EXPECT_EXIT(
raise(SIGABRT), testing::ExitedWithCode(3),
"") <<
"b_ar";
792 EXPECT_EXIT(
raise(SIGKILL), testing::KilledBySignal(SIGKILL),
"") <<
"foo";
793 ASSERT_EXIT(
raise(SIGUSR2), testing::KilledBySignal(SIGUSR2),
"") <<
"bar";
796 ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV),
"")
797 <<
"This failure is expected, too.";
798 },
"This failure is expected, too.");
800 # endif // GTEST_OS_WINDOWS 803 EXPECT_EXIT(
raise(SIGSEGV), testing::ExitedWithCode(0),
"")
804 <<
"This failure is expected.";
805 },
"This failure is expected.");
808 TEST_F(TestForDeathTest, ExitMacros) {
812 TEST_F(TestForDeathTest, ExitMacrosUsingFork) {
817 TEST_F(TestForDeathTest, InvalidStyle) {
820 EXPECT_DEATH(_exit(0),
"") <<
"This failure is expected.";
821 },
"This failure is expected.");
824 TEST_F(TestForDeathTest, DeathTestFailedOutput) {
827 EXPECT_DEATH(DieWithMessage(
"death\n"),
830 "[ DEATH ] death\n");
833 TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
837 fprintf(stderr,
"returning\n");
841 " Result: illegal return in test statement.\n" 843 "[ DEATH ] returning\n");
846 TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
849 EXPECT_EXIT(DieWithMessage(
"exiting with rc 1\n"),
850 testing::ExitedWithCode(3),
852 " Result: died but not with expected exit code:\n" 853 " Exited with exit status 1\n" 855 "[ DEATH ] exiting with rc 1\n");
858 TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
861 EXPECT_DEATH(DieWithMessage(
"line 1\nline 2\nline 3\n"),
862 "line 1\nxyz\nline 3\n"),
866 "[ DEATH ] line 3\n");
869 TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
871 EXPECT_DEATH(DieWithMessage(
"line 1\nline 2\nline 3\n"),
872 "line 1\nline 2\nline 3\n");
876 class MockDeathTestFactory :
public DeathTestFactory {
878 MockDeathTestFactory();
879 virtual bool Create(
const char* statement,
880 const ::testing::internal::RE* regex,
881 const char* file,
int line, DeathTest**
test);
884 void SetParameters(
bool create, DeathTest::TestRole role,
885 int status,
bool passed);
888 int AssumeRoleCalls()
const {
return assume_role_calls_; }
889 int WaitCalls()
const {
return wait_calls_; }
890 int PassedCalls()
const {
return passed_args_.size(); }
891 bool PassedArgument(
int n)
const {
return passed_args_[n]; }
892 int AbortCalls()
const {
return abort_args_.size(); }
893 DeathTest::AbortReason AbortArgument(
int n)
const {
894 return abort_args_[n];
896 bool TestDeleted()
const {
return test_deleted_; }
899 friend class MockDeathTest;
904 DeathTest::TestRole role_;
911 int assume_role_calls_;
916 std::vector<bool> passed_args_;
919 std::vector<DeathTest::AbortReason> abort_args_;
930 class MockDeathTest :
public DeathTest {
932 MockDeathTest(MockDeathTestFactory *parent,
933 TestRole role,
int status,
bool passed) :
934 parent_(parent), role_(role), status_(status), passed_(passed) {
936 virtual ~MockDeathTest() {
937 parent_->test_deleted_ =
true;
939 virtual TestRole AssumeRole() {
940 ++parent_->assume_role_calls_;
944 ++parent_->wait_calls_;
947 virtual bool Passed(
bool exit_status_ok) {
948 parent_->passed_args_.push_back(exit_status_ok);
951 virtual void Abort(AbortReason reason) {
952 parent_->abort_args_.push_back(reason);
956 MockDeathTestFactory*
const parent_;
957 const TestRole role_;
964 MockDeathTestFactory::MockDeathTestFactory()
966 role_(DeathTest::OVERSEE_TEST),
969 assume_role_calls_(0),
977 void MockDeathTestFactory::SetParameters(
bool create,
978 DeathTest::TestRole role,
979 int status,
bool passed) {
985 assume_role_calls_ = 0;
987 passed_args_.clear();
995 bool MockDeathTestFactory::Create(
const char* ,
996 const ::testing::internal::RE* ,
1000 test_deleted_ =
false;
1002 *test =
new MockDeathTest(
this, role_, status_, passed_);
1014 static testing::internal::ReplaceDeathTestFactory* replacer_;
1015 static MockDeathTestFactory* factory_;
1018 factory_ =
new MockDeathTestFactory;
1019 replacer_ =
new testing::internal::ReplaceDeathTestFactory(factory_);
1032 static void RunReturningDeathTest(
bool* flag) {
1040 testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_
1042 MockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL;
1046 TEST_F(MacroLogicDeathTest, NothingHappens) {
1048 factory_->SetParameters(
false, DeathTest::OVERSEE_TEST, 0,
true);
1049 EXPECT_DEATH(flag =
true,
"");
1051 EXPECT_EQ(0, factory_->AssumeRoleCalls());
1061 TEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) {
1063 factory_->SetParameters(
true, DeathTest::OVERSEE_TEST, 0,
true);
1064 EXPECT_DEATH(flag =
true,
"");
1066 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1076 TEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) {
1078 factory_->SetParameters(
true, DeathTest::OVERSEE_TEST, 1,
true);
1079 EXPECT_DEATH(flag =
true,
"");
1081 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1092 TEST_F(MacroLogicDeathTest, ChildPerformsReturn) {
1094 factory_->SetParameters(
true, DeathTest::EXECUTE_TEST, 0,
true);
1095 RunReturningDeathTest(&flag);
1097 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1101 EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1102 factory_->AbortArgument(0));
1108 TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
1110 factory_->SetParameters(
true, DeathTest::EXECUTE_TEST, 0,
true);
1111 EXPECT_DEATH(flag =
true,
"");
1113 EXPECT_EQ(1, factory_->AssumeRoleCalls());
1123 factory_->AbortArgument(0));
1124 EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1125 factory_->AbortArgument(1));
1131 TEST(SuccessRegistrationDeathTest, NoSuccessPart) {
1132 EXPECT_DEATH(_exit(1),
"");
1136 TEST(StreamingAssertionsDeathTest, DeathTest) {
1137 EXPECT_DEATH(_exit(1),
"") <<
"unexpected failure";
1138 ASSERT_DEATH(_exit(1),
"") <<
"unexpected failure";
1140 EXPECT_DEATH(_exit(0),
"") <<
"expected failure";
1141 },
"expected failure");
1143 ASSERT_DEATH(_exit(0),
"") <<
"expected failure";
1144 },
"expected failure");
1149 TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
1156 # if GTEST_OS_WINDOWS 1157 TEST(AutoHandleTest, AutoHandleWorks) {
1158 HANDLE handle = ::CreateEvent(NULL,
FALSE,
FALSE, NULL);
1159 ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1162 testing::internal::AutoHandle auto_handle(handle);
1167 auto_handle.Reset();
1168 EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle.Get());
1172 handle = ::CreateEvent(NULL,
FALSE,
FALSE, NULL);
1173 ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1174 auto_handle.Reset(handle);
1178 testing::internal::AutoHandle auto_handle2;
1179 EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());
1181 # endif // GTEST_OS_WINDOWS 1183 # if GTEST_OS_WINDOWS 1184 typedef unsigned __int64 BiggestParsable;
1185 typedef signed __int64 BiggestSignedParsable;
1187 typedef unsigned long long BiggestParsable;
1188 typedef signed long long BiggestSignedParsable;
1189 # endif // GTEST_OS_WINDOWS 1193 const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
1194 const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
1196 TEST(ParseNaturalNumberTest, RejectsInvalidFormat) {
1197 BiggestParsable
result = 0;
1200 EXPECT_FALSE(ParseNaturalNumber(
"non-number string", &result));
1213 TEST(ParseNaturalNumberTest, RejectsOverflownNumbers) {
1214 BiggestParsable result = 0;
1216 EXPECT_FALSE(ParseNaturalNumber(
"99999999999999999999999", &result));
1218 signed char char_result = 0;
1223 TEST(ParseNaturalNumberTest, AcceptsValidNumbers) {
1224 BiggestParsable result = 0;
1236 ASSERT_TRUE(ParseNaturalNumber(
"00000", &result));
1240 TEST(ParseNaturalNumberTest, AcceptsTypeLimits) {
1242 msg << kBiggestParsableMax;
1244 BiggestParsable result = 0;
1249 msg2 << kBiggestSignedParsableMax;
1251 BiggestSignedParsable signed_result = 0;
1252 EXPECT_TRUE(ParseNaturalNumber(msg2.GetString(), &signed_result));
1253 EXPECT_EQ(kBiggestSignedParsableMax, signed_result);
1259 EXPECT_TRUE(ParseNaturalNumber(msg3.GetString(), &int_result));
1265 unsigned int uint_result = 0;
1266 EXPECT_TRUE(ParseNaturalNumber(msg4.GetString(), &uint_result));
1270 TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
1271 short short_result = 0;
1272 ASSERT_TRUE(ParseNaturalNumber(
"123", &short_result));
1275 signed char char_result = 0;
1276 ASSERT_TRUE(ParseNaturalNumber(
"123", &char_result));
1280 # if GTEST_OS_WINDOWS 1281 TEST(EnvironmentTest, HandleFitsIntoSizeT) {
1287 # endif // GTEST_OS_WINDOWS 1291 TEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {
1293 "death inside CondDeathTestExpectMacro");
1295 "death inside CondDeathTestAssertMacro");
1302 TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
1306 fprintf(stderr, InDeathTestChild() ?
"Inside" :
"Outside");
1312 TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
1316 fprintf(stderr, InDeathTestChild() ?
"Inside" :
"Outside");
1322 #else // !GTEST_HAS_DEATH_TEST follows 1330 TEST(ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable) {
1337 "Death tests are not supported on this platform"));
1344 ASSERT_TRUE(NULL == strstr(output.c_str(),
"streamed message"));
1350 "Death tests are not supported on this platform"));
1356 ASSERT_TRUE(NULL == strstr(output.c_str(),
"streamed message"));
1366 TEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {
1372 #endif // !GTEST_HAS_DEATH_TEST 1379 TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
1402 TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
1410 <<
"exit in default switch handler";
class UnitTestImpl * GetUnitTestImpl()
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex)
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
GTEST_API_ std::string GetCapturedStderr()
#define EXPECT_STRNE(s1, s2)
static void SetUpTestCase()
#define EXPECT_NONFATAL_FAILURE(statement, substr)
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
#define ASSERT_NE(val1, val2)
TEST_F(TestInfoTest, Names)
#define GTEST_LOG_(severity)
#define ASSERT_EQ(val1, val2)
int ChDir(const char *dir)
UNITTEST_START int result
#define EXPECT_FATAL_FAILURE(statement, substr)
#define EXPECT_PRED1(pred, v1)
TEST_F(ListenerTest, DoesFoo)
UNITTEST_START char * output
bool GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests)
#define ASSERT_TRUE(condition)
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
boost::asio::deadline_timer timer(io_service)
TEST(GTestEnvVarTest, Dummy)
GTEST_API_ bool AlwaysTrue()
#define EXPECT_STREQ(expected, actual)
#define EXPECT_EQ(expected, actual)
GTEST_API_ void CaptureStderr()
void FuncWithAssert(int *n)
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
#define ASSERT_FALSE(condition)
static void TearDownTestCase()
TEST(IsXDigitTest, WorksForNarrowAscii)