mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
StopOnFailure now works again
This commit is contained in:
parent
b87bff21cd
commit
4890a1d80a
@ -46,7 +46,7 @@ TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown
|
||||
CHECK_NOTHROW( thisThrows() );
|
||||
}
|
||||
|
||||
INTERNAL_CATCH_TESTCASE_NORETURN( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
|
||||
TEST_CASE_NORETURN( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
|
||||
{
|
||||
throw std::domain_error( "unexpected exception" );
|
||||
/*NOTREACHED*/
|
||||
|
@ -194,6 +194,12 @@ namespace Catch
|
||||
m_config.stream() << "Unexpected";
|
||||
m_config.stream() << " exception with message: '" << resultInfo.getMessage() << "'";
|
||||
break;
|
||||
case ResultWas::DidntThrowException:
|
||||
if( resultInfo.hasExpression() )
|
||||
m_config.stream() << " because no exception was thrown where one was expected";
|
||||
else
|
||||
m_config.stream() << "No exception thrown where one was expected";
|
||||
break;
|
||||
case ResultWas::Info:
|
||||
m_config.stream() << "info:\n'" << resultInfo.getMessage() << "'";
|
||||
break;
|
||||
@ -204,6 +210,13 @@ namespace Catch
|
||||
m_config.stream() << "failed with message: '" << resultInfo.getMessage() << "'";
|
||||
break;
|
||||
default:
|
||||
if( !resultInfo.hasExpression() )
|
||||
{
|
||||
if( resultInfo.ok() )
|
||||
m_config.stream() << " succeeded";
|
||||
else
|
||||
m_config.stream() << " failed";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -537,8 +537,8 @@ inline bool isTrue
|
||||
} // end namespace Catch
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_ACCEPT_RESULT2( result, stopOnFailure ) \
|
||||
if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptResult( result ) ) \
|
||||
#define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure ) \
|
||||
if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptExpression( expr ) ) \
|
||||
{ \
|
||||
if( action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \
|
||||
if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \
|
||||
@ -546,34 +546,34 @@ inline bool isTrue
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
|
||||
Catch::Hub::getResultCapture().acceptExpression( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr );
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr ), stopOnFailure );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \
|
||||
try \
|
||||
{ \
|
||||
using namespace Catch; \
|
||||
expr; \
|
||||
Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
|
||||
} \
|
||||
catch( ... ) \
|
||||
{ \
|
||||
using namespace Catch; \
|
||||
Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
|
||||
try \
|
||||
{ \
|
||||
using namespace Catch; \
|
||||
expr; \
|
||||
Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::DidntThrowException ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure ); \
|
||||
} \
|
||||
catch( Catch::TestFailureException& ) \
|
||||
{ \
|
||||
throw; \
|
||||
} \
|
||||
catch( exceptionType ) \
|
||||
{ \
|
||||
using namespace Catch; \
|
||||
Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -581,8 +581,7 @@ inline bool isTrue
|
||||
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
|
||||
catch( ... ) \
|
||||
{ \
|
||||
using namespace Catch; \
|
||||
Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,7 +28,7 @@ struct ResultWas{ enum OfType
|
||||
ExpressionFailed = FailureBit | 1,
|
||||
ExplicitFailure = FailureBit | 2,
|
||||
|
||||
Exception = 0x110,
|
||||
Exception = 0x100 | FailureBit,
|
||||
|
||||
ThrewException = Exception | 1,
|
||||
DidntThrowException = Exception | 2
|
||||
|
Loading…
Reference in New Issue
Block a user