mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 11:43:29 +01:00
print messages when unexpected exceptions are thrown
This commit is contained in:
parent
6e091d3991
commit
9a07dde16d
@ -38,7 +38,10 @@ namespace Catch {
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
ScopedMessage::~ScopedMessage() {
|
ScopedMessage::~ScopedMessage() {
|
||||||
getResultCapture().popScopedMessage( m_info );
|
if (!std::uncaught_exception())
|
||||||
|
{
|
||||||
|
getResultCapture().popScopedMessage(m_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +138,11 @@ namespace Catch {
|
|||||||
case ResultWas::ThrewException:
|
case ResultWas::ThrewException:
|
||||||
colour = Colour::Error;
|
colour = Colour::Error;
|
||||||
passOrFail = "FAILED";
|
passOrFail = "FAILED";
|
||||||
messageLabel = "due to unexpected exception with message";
|
messageLabel = "due to unexpected exception with ";
|
||||||
|
if (_stats.infoMessages.size() == 1)
|
||||||
|
messageLabel += "message";
|
||||||
|
if (_stats.infoMessages.size() > 1)
|
||||||
|
messageLabel += "messages";
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
colour = Colour::Error;
|
colour = Colour::Error;
|
||||||
|
@ -209,3 +209,18 @@ TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!thr
|
|||||||
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user