Makes TestForDeathTest.CRTDebugDeath only run when _DEBUG is defined
PiperOrigin-RevId: 417678422 Change-Id: I8e42a906459b8fd5a7789a7ed728d12448046c44
This commit is contained in:
parent
9a32aee22d
commit
71d4e2f742
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user