mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 02:25:38 +02:00
Context methods are non-static - accessed via interface
This is a move towards allowing multiple contexts - with the concept of a (possibly thread local) "current" context
This commit is contained in:
@@ -22,11 +22,11 @@ struct TestFailureException{};
|
||||
class ScopedInfo {
|
||||
public:
|
||||
ScopedInfo() : m_oss() {
|
||||
Context::getResultCapture().pushScopedInfo( this );
|
||||
getCurrentContext().getResultCapture().pushScopedInfo( this );
|
||||
}
|
||||
|
||||
~ScopedInfo() {
|
||||
Context::getResultCapture().popScopedInfo( this );
|
||||
getCurrentContext().getResultCapture().popScopedInfo( this );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -50,7 +50,7 @@ inline bool isTrue( bool value ){ return value; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure, originalExpr ) \
|
||||
if( Catch::ResultAction::Value internal_catch_action = Catch::Context::getResultCapture().acceptExpression( expr ) ) \
|
||||
if( Catch::ResultAction::Value internal_catch_action = Catch::getCurrentContext().getResultCapture().acceptExpression( expr ) ) \
|
||||
{ \
|
||||
if( internal_catch_action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \
|
||||
if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \
|
||||
@@ -64,19 +64,19 @@ inline bool isTrue( bool value ){ return value; }
|
||||
}catch( Catch::TestFailureException& ){ \
|
||||
throw; \
|
||||
} catch( ... ){ \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
|
||||
throw; \
|
||||
}}while( Catch::isTrue( false ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_IF( expr, isNot, stopOnFailure, macroName ) \
|
||||
INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \
|
||||
if( Catch::Context::getResultCapture().getLastResult()->ok() )
|
||||
if( Catch::getCurrentContext().getResultCapture().getLastResult()->ok() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_ELSE( expr, isNot, stopOnFailure, macroName ) \
|
||||
INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \
|
||||
if( !Catch::Context::getResultCapture().getLastResult()->ok() )
|
||||
if( !Catch::getCurrentContext().getResultCapture().getLastResult()->ok() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \
|
||||
@@ -87,7 +87,7 @@ inline bool isTrue( bool value ){ return value; }
|
||||
} \
|
||||
catch( ... ) \
|
||||
{ \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -111,12 +111,12 @@ inline bool isTrue( bool value ){ return value; }
|
||||
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
|
||||
catch( ... ) \
|
||||
{ \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \
|
||||
Catch::Context::getResultCapture().acceptExpression( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) );
|
||||
Catch::getCurrentContext().getResultCapture().acceptExpression( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_SCOPED_INFO( log ) \
|
||||
@@ -130,7 +130,7 @@ inline bool isTrue( bool value ){ return value; }
|
||||
}catch( Catch::TestFailureException& ){ \
|
||||
throw; \
|
||||
} catch( ... ){ \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
|
||||
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::getCurrentContext().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
|
||||
throw; \
|
||||
}}while( Catch::isTrue( false ) )
|
||||
|
||||
|
Reference in New Issue
Block a user