Added special catch for std::exception in GTEST_TEST_NO_THROW_

This commit is contained in:
Jonny007-MKD
2018-09-13 10:24:10 +02:00
parent f1d7b3947d
commit fad53c8498
2 changed files with 29 additions and 3 deletions

View File

@@ -3330,6 +3330,9 @@ TEST_F(SingleEvaluationTest, OtherCases) {
void ThrowAnInteger() {
throw 1;
}
void ThrowAnException(const char* what) {
throw std::runtime_error(what);
}
// Tests that assertion arguments are evaluated exactly once.
TEST_F(SingleEvaluationTest, ExceptionTests) {
@@ -3812,6 +3815,9 @@ 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(ThrowAnException("blablubb")),
"Expected: ThrowAnException(\"blablubb\") doesn't throw an exception."
"\n Actual: it throws: blablubb");
}
// Tests ASSERT_ANY_THROW.
@@ -4553,6 +4559,9 @@ 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(ThrowAnException("blablubb")),
"Expected: ThrowAnException(\"blablubb\") doesn't throw an "
"exception.\n Actual: it throws: blablubb");
}
// Tests EXPECT_ANY_THROW.