print messages when unexpected exceptions are thrown

This commit is contained in:
dvirtz 2017-03-31 01:06:35 +03:00 committed by Martin Hořeňovský
parent 6e091d3991
commit 9a07dde16d
3 changed files with 24 additions and 2 deletions

View file

@ -209,3 +209,18 @@ TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!thr
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
}
TEST_CASE( "#748 - captures with unexpected exceptions", "[!shouldfail]" ) {
int answer = 42;
CAPTURE(answer);
// the message should be printed on the first two sections but not on the third
SECTION( "outside assertions" ) {
thisThrows();
}
SECTION( "inside REQUIRE_NOTHROW" ) {
REQUIRE_NOTHROW(thisThrows());
}
SECTION( "inside REQUIRE_THROWS" ) {
REQUIRE_THROWS(thisThrows());
}
}