aboutsummaryrefslogtreecommitdiffstats
path: root/googletest/test
diff options
context:
space:
mode:
authorIhor Dutchak <ihor.youw@gmail.com>2019-08-06 16:22:08 +0300
committerIhor Dutchak <ihor.youw@gmail.com>2019-10-30 21:57:48 +0200
commitf626deda19e54adaaff1cd0d7b22421f934dec55 (patch)
tree15dd8a196df5958e5a0ac439944deac6b0b4b084 /googletest/test
parent11be5f534cfca1139880dd66727c15f5bd1e0780 (diff)
downloadgoogletest-f626deda19e54adaaff1cd0d7b22421f934dec55.tar.gz
googletest-f626deda19e54adaaff1cd0d7b22421f934dec55.tar.bz2
googletest-f626deda19e54adaaff1cd0d7b22421f934dec55.zip
Added special catch for std::exception in GTEST_TEST_NO_THROW_
Diffstat (limited to 'googletest/test')
-rw-r--r--googletest/test/gtest_unittest.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 2b00b70a..2496c59d 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -3351,6 +3351,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) {
@@ -3830,6 +3833,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.
@@ -4567,6 +4575,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.