Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest-death-test_test.cc File Reference
Include dependency graph for gtest-death-test_test.cc:

Go to the source code of this file.

Functions

 TEST (ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable)
 
void FuncWithAssert (int *n)
 
 TEST (ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported)
 
 TEST (ConditionalDeathMacrosSyntaxDeathTest, SingleStatement)
 
 TEST (ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement)
 
 TEST (NotADeathTest, Test)
 

Function Documentation

◆ FuncWithAssert()

void FuncWithAssert ( int * n)

Definition at line 1360 of file gtest-death-test_test.cc.

1360 {
1361 ASSERT_DEATH_IF_SUPPORTED(return;, "");
1362 (*n)++;
1363}
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex)
Here is the caller graph for this function:

◆ TEST() [1/5]

TEST ( ConditionalDeathMacrosSyntaxDeathTest ,
SingleStatement  )

Definition at line 1380 of file gtest-death-test_test.cc.

1380 {
1381 if (AlwaysFalse())
1382 // This would fail if executed; this is a compilation test only
1383 ASSERT_DEATH_IF_SUPPORTED(return, "");
1384
1385 if (AlwaysTrue())
1386 EXPECT_DEATH_IF_SUPPORTED(_exit(1), "");
1387 else
1388 // This empty "else" branch is meant to ensure that EXPECT_DEATH
1389 // doesn't expand into an "if" statement without an "else"
1390 ; // NOLINT
1391
1392 if (AlwaysFalse())
1393 ASSERT_DEATH_IF_SUPPORTED(return, "") << "did not die";
1394
1395 if (AlwaysFalse())
1396 ; // NOLINT
1397 else
1398 EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << 1 << 2 << 3;
1399}
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)

◆ TEST() [2/5]

TEST ( ConditionalDeathMacrosSyntaxDeathTest ,
SwitchStatement  )

Definition at line 1403 of file gtest-death-test_test.cc.

1403 {
1404 // Microsoft compiler usually complains about switch statements without
1405 // case labels. We suppress that warning for this test.
1407
1408 switch (0)
1409 default:
1410 ASSERT_DEATH_IF_SUPPORTED(_exit(1), "")
1411 << "exit in default switch handler";
1412
1413 switch (0)
1414 case 0:
1415 EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in switch case";
1416
1418}
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition gtest-port.h:324
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition gtest-port.h:325
switch(session->session_state)

◆ TEST() [3/5]

TEST ( ConditionalDeathMacrosTest ,
AssertDeatDoesNotReturnhIfUnsupported  )

Definition at line 1367 of file gtest-death-test_test.cc.

1367 {
1368 int n = 0;
1369 FuncWithAssert(&n);
1370 EXPECT_EQ(1, n);
1371}
void FuncWithAssert(int *n)
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
Here is the call graph for this function:

◆ TEST() [4/5]

TEST ( ConditionalDeathMacrosTest ,
WarnsWhenDeathTestsNotAvailable  )

Definition at line 1331 of file gtest-death-test_test.cc.

1331 {
1332 // Empty statement will not crash, but that should not trigger a failure
1333 // when death tests are not supported.
1334 CaptureStderr();
1336 std::string output = GetCapturedStderr();
1337 ASSERT_TRUE(NULL != strstr(output.c_str(),
1338 "Death tests are not supported on this platform"));
1339 ASSERT_TRUE(NULL != strstr(output.c_str(), ";"));
1340
1341 // The streamed message should not be printed as there is no test failure.
1342 CaptureStderr();
1343 EXPECT_DEATH_IF_SUPPORTED(;, "") << "streamed message";
1344 output = GetCapturedStderr();
1345 ASSERT_TRUE(NULL == strstr(output.c_str(), "streamed message"));
1346
1347 CaptureStderr();
1348 ASSERT_DEATH_IF_SUPPORTED(;, ""); // NOLINT
1349 output = GetCapturedStderr();
1350 ASSERT_TRUE(NULL != strstr(output.c_str(),
1351 "Death tests are not supported on this platform"));
1352 ASSERT_TRUE(NULL != strstr(output.c_str(), ";"));
1353
1354 CaptureStderr();
1355 ASSERT_DEATH_IF_SUPPORTED(;, "") << "streamed message"; // NOLINT
1356 output = GetCapturedStderr();
1357 ASSERT_TRUE(NULL == strstr(output.c_str(), "streamed message"));
1358}
#define ASSERT_TRUE(condition)
Definition gtest.h:1901

◆ TEST() [5/5]

TEST ( NotADeathTest ,
Test  )

Definition at line 1422 of file gtest-death-test_test.cc.

1422 {
1423 SUCCEED();
1424}
#define SUCCEED()
Definition gtest.h:1867