aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gtest_output_test_golden_lin.txt26
-rw-r--r--test/gtest_unittest.cc62
2 files changed, 55 insertions, 33 deletions
diff --git a/test/gtest_output_test_golden_lin.txt b/test/gtest_output_test_golden_lin.txt
index ace88d07..74ed7371 100644
--- a/test/gtest_output_test_golden_lin.txt
+++ b/test/gtest_output_test_golden_lin.txt
@@ -7,7 +7,7 @@ Expected: true
gtest_output_test_.cc:#: Failure
Value of: 3
Expected: 2
-[==========] Running 52 tests from 22 test cases.
+[==========] Running 54 tests from 22 test cases.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -270,7 +270,7 @@ test DefinedUsingTEST is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
case.
[ FAILED ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
-[----------] 7 tests from ExpectNonfatalFailureTest
+[----------] 8 tests from ExpectNonfatalFailureTest
[ RUN ] ExpectNonfatalFailureTest.CanReferenceGlobalVariables
[ OK ] ExpectNonfatalFailureTest.CanReferenceGlobalVariables
[ RUN ] ExpectNonfatalFailureTest.CanReferenceLocalVariables
@@ -313,7 +313,13 @@ gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 0 failures
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementReturns
-[----------] 7 tests from ExpectFatalFailureTest
+[ RUN ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
+(expecting a failure)
+gtest.cc:#: Failure
+Expected: 1 non-fatal failure
+ Actual: 0 failures
+[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
+[----------] 8 tests from ExpectFatalFailureTest
[ RUN ] ExpectFatalFailureTest.CanReferenceGlobalVariables
[ OK ] ExpectFatalFailureTest.CanReferenceGlobalVariables
[ RUN ] ExpectFatalFailureTest.CanReferenceLocalStaticVariables
@@ -356,6 +362,12 @@ gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 0 failures
[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementReturns
+[ RUN ] ExpectFatalFailureTest.FailsWhenStatementThrows
+(expecting a failure)
+gtest.cc:#: Failure
+Expected: 1 fatal failure
+ Actual: 0 failures
+[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows
[----------] 2 tests from TypedTest/0, where TypeParam = int
[ RUN ] TypedTest/0.Success
[ OK ] TypedTest/0.Success
@@ -496,9 +508,9 @@ FooEnvironment::TearDown() called.
gtest_output_test_.cc:#: Failure
Failed
Expected fatal failure.
-[==========] 52 tests from 22 test cases ran.
+[==========] 54 tests from 22 test cases ran.
[ PASSED ] 19 tests.
-[ FAILED ] 33 tests, listed below:
+[ FAILED ] 35 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine
@@ -521,10 +533,12 @@ Expected fatal failure.
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementReturns
+[ FAILED ] ExpectNonfatalFailureTest.FailsWhenStatementThrows
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
[ FAILED ] ExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementReturns
+[ FAILED ] ExpectFatalFailureTest.FailsWhenStatementThrows
[ FAILED ] TypedTest/0.Failure, where TypeParam = int
[ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
[ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
@@ -533,7 +547,7 @@ Expected fatal failure.
[ FAILED ] ExpectFailureTest.ExpectFatalFailureOnAllThreads
[ FAILED ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads
-33 FAILED TESTS
+35 FAILED TESTS
 YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index faf01a38..4bac8a69 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -2869,31 +2869,37 @@ TEST(AssertionTest, ASSERT_GT) {
#if GTEST_HAS_EXCEPTIONS
+void ThrowNothing() {}
+
+
// Tests ASSERT_THROW.
TEST(AssertionTest, ASSERT_THROW) {
ASSERT_THROW(ThrowAnInteger(), int);
- EXPECT_FATAL_FAILURE(ASSERT_THROW(ThrowAnInteger(), bool),
- "Expected: ThrowAnInteger() throws an exception of type"\
- " bool.\n Actual: it throws a different type.");
- EXPECT_FATAL_FAILURE(ASSERT_THROW(1, bool),
- "Expected: 1 throws an exception of type bool.\n"\
- " Actual: it throws nothing.");
+ EXPECT_FATAL_FAILURE(
+ ASSERT_THROW(ThrowAnInteger(), bool),
+ "Expected: ThrowAnInteger() throws an exception of type bool.\n"
+ " Actual: it throws a different type.");
+ EXPECT_FATAL_FAILURE(
+ ASSERT_THROW(ThrowNothing(), bool),
+ "Expected: ThrowNothing() throws an exception of type bool.\n"
+ " Actual: it throws nothing.");
}
// Tests ASSERT_NO_THROW.
TEST(AssertionTest, ASSERT_NO_THROW) {
- ASSERT_NO_THROW(1);
+ ASSERT_NO_THROW(ThrowNothing());
EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),
- "Expected: ThrowAnInteger() doesn't throw an exception."\
+ "Expected: ThrowAnInteger() doesn't throw an exception."
"\n Actual: it throws.");
}
// Tests ASSERT_ANY_THROW.
TEST(AssertionTest, ASSERT_ANY_THROW) {
ASSERT_ANY_THROW(ThrowAnInteger());
- EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(1),
- "Expected: 1 throws an exception.\n Actual: it "\
- "doesn't.");
+ EXPECT_FATAL_FAILURE(
+ ASSERT_ANY_THROW(ThrowNothing()),
+ "Expected: ThrowNothing() throws an exception.\n"
+ " Actual: it doesn't.");
}
#endif // GTEST_HAS_EXCEPTIONS
@@ -3149,7 +3155,7 @@ TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {
TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
if (false)
- EXPECT_THROW(1, bool);
+ EXPECT_THROW(ThrowNothing(), bool);
if (true)
EXPECT_THROW(ThrowAnInteger(), int);
@@ -3160,12 +3166,12 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
EXPECT_NO_THROW(ThrowAnInteger());
if (true)
- EXPECT_NO_THROW(1);
+ EXPECT_NO_THROW(ThrowNothing());
else
;
if (false)
- EXPECT_ANY_THROW(1);
+ EXPECT_ANY_THROW(ThrowNothing());
if (true)
EXPECT_ANY_THROW(ThrowAnInteger());
@@ -3424,27 +3430,29 @@ TEST(ExpectTest, EXPECT_GT) {
TEST(ExpectTest, EXPECT_THROW) {
EXPECT_THROW(ThrowAnInteger(), int);
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),
- "Expected: ThrowAnInteger() throws an exception of "\
+ "Expected: ThrowAnInteger() throws an exception of "
"type bool.\n Actual: it throws a different type.");
- EXPECT_NONFATAL_FAILURE(EXPECT_THROW(1, bool),
- "Expected: 1 throws an exception of type bool.\n"\
- " Actual: it throws nothing.");
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_THROW(ThrowNothing(), bool),
+ "Expected: ThrowNothing() throws an exception of type bool.\n"
+ " Actual: it throws nothing.");
}
// Tests EXPECT_NO_THROW.
TEST(ExpectTest, EXPECT_NO_THROW) {
- EXPECT_NO_THROW(1);
+ EXPECT_NO_THROW(ThrowNothing());
EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),
- "Expected: ThrowAnInteger() doesn't throw an "\
+ "Expected: ThrowAnInteger() doesn't throw an "
"exception.\n Actual: it throws.");
}
// Tests EXPECT_ANY_THROW.
TEST(ExpectTest, EXPECT_ANY_THROW) {
EXPECT_ANY_THROW(ThrowAnInteger());
- EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(1),
- "Expected: 1 throws an exception.\n Actual: it "\
- "doesn't.");
+ EXPECT_NONFATAL_FAILURE(
+ EXPECT_ANY_THROW(ThrowNothing()),
+ "Expected: ThrowNothing() throws an exception.\n"
+ " Actual: it doesn't.");
}
#endif // GTEST_HAS_EXCEPTIONS
@@ -5056,8 +5064,8 @@ TEST(StreamingAssertionsTest, Throw) {
}
TEST(StreamingAssertionsTest, NoThrow) {
- EXPECT_NO_THROW(1) << "unexpected failure";
- ASSERT_NO_THROW(1) << "unexpected failure";
+ EXPECT_NO_THROW(ThrowNothing()) << "unexpected failure";
+ ASSERT_NO_THROW(ThrowNothing()) << "unexpected failure";
EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) <<
"expected failure", "expected failure");
EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) <<
@@ -5067,9 +5075,9 @@ TEST(StreamingAssertionsTest, NoThrow) {
TEST(StreamingAssertionsTest, AnyThrow) {
EXPECT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
ASSERT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
- EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(1) <<
+ EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(ThrowNothing()) <<
"expected failure", "expected failure");
- EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(1) <<
+ EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(ThrowNothing()) <<
"expected failure", "expected failure");
}