mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-16 18:15:42 +02:00
AssertionResultBuilder can be constructed from result type
This commit is contained in:
@@ -101,11 +101,11 @@ inline bool isTrue( bool value ){ return value; }
|
||||
#define INTERNAL_CATCH_TEST( expr, isFalse, stopOnFailure, macroName ) \
|
||||
do { try { \
|
||||
Catch::getResultCapture().acceptAssertionInfo( Catch::AssertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr ) ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( isFalse )->*expr ), stopOnFailure, expr ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder()->*expr ).setIsFalse( isFalse ), stopOnFailure, expr ); \
|
||||
} catch( Catch::TestFailureException& ) { \
|
||||
throw; \
|
||||
} catch( ... ) { \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), false, expr ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), false, expr ); \
|
||||
throw; \
|
||||
} } while( Catch::isTrue( false ) )
|
||||
|
||||
@@ -124,10 +124,10 @@ inline bool isTrue( bool value ){ return value; }
|
||||
try { \
|
||||
Catch::getResultCapture().acceptAssertionInfo( Catch::AssertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr ) ); \
|
||||
expr; \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), stopOnFailure, false ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -136,26 +136,26 @@ inline bool isTrue( bool value ){ return value; }
|
||||
Catch::getResultCapture().acceptAssertionInfo( Catch::AssertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr ) ); \
|
||||
if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \
|
||||
expr; \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \
|
||||
} \
|
||||
} \
|
||||
catch( Catch::TestFailureException& ) { \
|
||||
throw; \
|
||||
} \
|
||||
catch( exceptionType ) { \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( Catch::ResultWas::Ok ), stopOnFailure, false ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, stopOnFailure, macroName ) \
|
||||
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
|
||||
catch( ... ) { \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::AssertionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), stopOnFailure, false ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder().setResultType( resultType ) << reason, stopOnFailure, true );
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( Catch::AssertionResultBuilder( resultType ) << reason, stopOnFailure, true );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_SCOPED_INFO( log ) \
|
||||
@@ -170,7 +170,7 @@ inline bool isTrue( bool value ){ return value; }
|
||||
} catch( Catch::TestFailureException& ) { \
|
||||
throw; \
|
||||
} catch( ... ) { \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::AssertionResultBuilder().setResultType( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), false, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::AssertionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), false, false ); \
|
||||
throw; \
|
||||
}}while( Catch::isTrue( false ) )
|
||||
|
||||
|
Reference in New Issue
Block a user