diff options
author | Derek Mauro <dmauro@google.com> | 2021-12-21 21:15:49 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-12-21 21:16:17 (GMT) |
commit | 71d4e2f7423274d178b446e94b88082559f2fa7a (patch) | |
tree | f21f942b2e90441769a2770be71794e81799422e /googletest/test | |
parent | 9a32aee22d771387c494be2d8519fbdf46a713b2 (diff) | |
download | googletest-71d4e2f7423274d178b446e94b88082559f2fa7a.zip googletest-71d4e2f7423274d178b446e94b88082559f2fa7a.tar.gz googletest-71d4e2f7423274d178b446e94b88082559f2fa7a.tar.bz2 |
Makes TestForDeathTest.CRTDebugDeath only run when _DEBUG is defined
PiperOrigin-RevId: 417678422
Change-Id: I8e42a906459b8fd5a7789a7ed728d12448046c44
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-death-test-test.cc | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index e7e0cd7..62a84b4 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -668,35 +668,19 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) { # if GTEST_OS_WINDOWS -// Tests that EXPECT_DEBUG_DEATH works as expected when in debug mode -// the Windows CRT crashes the process with an assertion failure. +// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode +// In debug mode, the calls to _CrtSetReportMode and _CrtSetReportFile enable +// the dumping of assertions to stderr. Tests that EXPECT_DEATH works as +// expected when in CRT debug mode (compiled with /MTd or /MDd, which defines +// _DEBUG) the Windows CRT crashes the process with an assertion failure. // 1. Asserts on death. // 2. Has no side effect (doesn't pop up a window or wait for user input). -// -// And in opt mode, it: -// 1. Has side effects but does not assert. +#ifdef _DEBUG TEST_F(TestForDeathTest, CRTDebugDeath) { - int sideeffect = 0; - - // Put the regex in a local variable to make sure we don't get an "unused" - // warning in opt mode. - const char* regex = "dup.* : Assertion failed"; - - EXPECT_DEBUG_DEATH(DieInCRTDebugElse12(&sideeffect), regex) + EXPECT_DEATH(DieInCRTDebugElse12(nullptr), "dup.* : Assertion failed") << "Must accept a streamed message"; - -# ifdef NDEBUG - - // Checks that the assignment occurs in opt mode (sideeffect). - EXPECT_EQ(12, sideeffect); - -# else - - // Checks that the assignment does not occur in dbg mode (no sideeffect). - EXPECT_EQ(0, sideeffect); - -# endif } +#endif // _DEBUG # endif // GTEST_OS_WINDOWS |