mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
integrated AssertionHandler into INTERNAL_CATCH_THROWS_AS
This commit is contained in:
parent
f033f4f184
commit
8a97beece2
@ -90,6 +90,9 @@ namespace Catch {
|
|||||||
void AssertionHandler::handle( ResultWas::OfType resultType ) {
|
void AssertionHandler::handle( ResultWas::OfType resultType ) {
|
||||||
handle( resultType, nullptr, false );
|
handle( resultType, nullptr, false );
|
||||||
}
|
}
|
||||||
|
auto AssertionHandler::allowThrows() const -> bool {
|
||||||
|
return getCurrentContext().getConfig()->allowThrows();
|
||||||
|
}
|
||||||
|
|
||||||
auto AssertionHandler::shouldDebugBreak() const -> bool {
|
auto AssertionHandler::shouldDebugBreak() const -> bool {
|
||||||
return m_shouldDebugBreak;
|
return m_shouldDebugBreak;
|
||||||
|
@ -54,6 +54,7 @@ namespace Catch {
|
|||||||
void handle( AssertionResultData const& resultData, ITransientExpression const* expr );
|
void handle( AssertionResultData const& resultData, ITransientExpression const* expr );
|
||||||
|
|
||||||
auto shouldDebugBreak() const -> bool;
|
auto shouldDebugBreak() const -> bool;
|
||||||
|
auto allowThrows() const -> bool;
|
||||||
void reactWithDebugBreak() const;
|
void reactWithDebugBreak() const;
|
||||||
void reactWithoutDebugBreak() const;
|
void reactWithoutDebugBreak() const;
|
||||||
void useActiveException( ResultDisposition::Flags resultDisposition );
|
void useActiveException( ResultDisposition::Flags resultDisposition );
|
||||||
|
@ -112,21 +112,21 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
|
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( catchAssertionHandler.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \
|
||||||
} \
|
} \
|
||||||
catch( exceptionType const& ) { \
|
catch( exceptionType const& ) { \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
} \
|
} \
|
||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
__catchResult.useActiveException( resultDisposition ); \
|
catchAssertionHandler.useActiveException(); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user