diff options
author | Xiaoyi Zhang <zhangxy@google.com> | 2019-11-05 17:08:09 -0500 |
---|---|---|
committer | Xiaoyi Zhang <zhangxy@google.com> | 2019-11-05 17:08:09 -0500 |
commit | 3e062a6efe7a2044660af0fd7dfa42c47756f71f (patch) | |
tree | 3569100578732ff48547e6df1d2da32a6adc86d3 /googletest/test | |
parent | 8697709e0308af4cd5b09dc108480804e5447cf0 (diff) | |
parent | f626deda19e54adaaff1cd0d7b22421f934dec55 (diff) | |
download | googletest-3e062a6efe7a2044660af0fd7dfa42c47756f71f.tar.gz googletest-3e062a6efe7a2044660af0fd7dfa42c47756f71f.tar.bz2 googletest-3e062a6efe7a2044660af0fd7dfa42c47756f71f.zip |
Merge pull request #2373 from Youw:master
PiperOrigin-RevId: 278601074
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/gtest_unittest.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index d17a1554..74379abc 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -3348,6 +3348,9 @@ TEST_F(SingleEvaluationTest, OtherCases) { void ThrowAnInteger() { throw 1; } +void ThrowRuntimeError(const char* what) { + throw std::runtime_error(what); +} // Tests that assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, ExceptionTests) { @@ -3827,6 +3830,11 @@ TEST(AssertionTest, ASSERT_NO_THROW) { EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an exception." "\n Actual: it throws."); + EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowRuntimeError("A description")), + "Expected: ThrowRuntimeError(\"A description\") " + "doesn't throw an exception.\n " + "Actual: it throws std::exception-derived exception " + "with description: \"A description\"."); } // Tests ASSERT_ANY_THROW. @@ -4564,6 +4572,11 @@ TEST(ExpectTest, EXPECT_NO_THROW) { EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an " "exception.\n Actual: it throws."); + EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowRuntimeError("A description")), + "Expected: ThrowRuntimeError(\"A description\") " + "doesn't throw an exception.\n " + "Actual: it throws std::exception-derived exception " + "with description: \"A description\"."); } // Tests EXPECT_ANY_THROW. |