mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Collapsed alternate capture macros now originals are redundant
This commit is contained in:
parent
8d21b4a916
commit
b59e0ed48a
@ -125,10 +125,6 @@ namespace Catch {
|
|||||||
throw Catch::TestFailureException();
|
throw Catch::TestFailureException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertionHandler::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
|
||||||
m_assertionInfo.resultDisposition = resultDisposition;
|
|
||||||
useActiveException();
|
|
||||||
}
|
|
||||||
void AssertionHandler::useActiveException() {
|
void AssertionHandler::useActiveException() {
|
||||||
handle( ResultWas::ThrewException, Catch::translateActiveException().c_str() );
|
handle( ResultWas::ThrewException, Catch::translateActiveException().c_str() );
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ namespace Catch {
|
|||||||
auto allowThrows() 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();
|
void useActiveException();
|
||||||
void setExceptionGuard();
|
void setExceptionGuard();
|
||||||
void unsetExceptionGuard();
|
void unsetExceptionGuard();
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
// We can speedup compilation significantly by breaking into debugger lower in
|
// We can speedup compilation significantly by breaking into debugger lower in
|
||||||
// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER
|
// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER
|
||||||
// macro in each assertion
|
// macro in each assertion
|
||||||
#define INTERNAL_CATCH_REACT( resultBuilder ) \
|
#define INTERNAL_CATCH_REACT( handler ) \
|
||||||
resultBuilder.react();
|
|
||||||
#define INTERNAL_CATCH_REACT2( handler ) \
|
|
||||||
handler.reactWithDebugBreak();
|
handler.reactWithDebugBreak();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -29,8 +27,7 @@
|
|||||||
// This can potentially cause false negative, if the test code catches
|
// This can potentially cause false negative, if the test code catches
|
||||||
// the exception before it propagates back up to the runner.
|
// the exception before it propagates back up to the runner.
|
||||||
#define INTERNAL_CATCH_TRY( capturer ) capturer.setExceptionGuard();
|
#define INTERNAL_CATCH_TRY( capturer ) capturer.setExceptionGuard();
|
||||||
#define INTERNAL_CATCH_CATCH( capturer, disposition ) capturer.unsetExceptionGuard();
|
#define INTERNAL_CATCH_CATCH( capturer ) capturer.unsetExceptionGuard();
|
||||||
#define INTERNAL_CATCH_CATCH2( capturer ) capturer.unsetExceptionGuard();
|
|
||||||
|
|
||||||
#else // CATCH_CONFIG_FAST_COMPILE
|
#else // CATCH_CONFIG_FAST_COMPILE
|
||||||
|
|
||||||
@ -41,16 +38,12 @@
|
|||||||
// and/or an exception thrown and takes appropriate action.
|
// and/or an exception thrown and takes appropriate action.
|
||||||
// This needs to be done as a macro so the debugger will stop in the user
|
// This needs to be done as a macro so the debugger will stop in the user
|
||||||
// source code rather than in Catch library code
|
// source code rather than in Catch library code
|
||||||
#define INTERNAL_CATCH_REACT( resultBuilder ) \
|
#define INTERNAL_CATCH_REACT( handler ) \
|
||||||
if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
|
|
||||||
resultBuilder.react();
|
|
||||||
#define INTERNAL_CATCH_REACT2( handler ) \
|
|
||||||
if( handler.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
|
if( handler.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
|
||||||
handler.reactWithoutDebugBreak();
|
handler.reactWithoutDebugBreak();
|
||||||
|
|
||||||
#define INTERNAL_CATCH_TRY( capturer ) try
|
#define INTERNAL_CATCH_TRY( capturer ) try
|
||||||
#define INTERNAL_CATCH_CATCH( capturer, disposition ) catch(...) { capturer.useActiveException( disposition ); }
|
#define INTERNAL_CATCH_CATCH( capturer ) catch(...) { capturer.useActiveException(); }
|
||||||
#define INTERNAL_CATCH_CATCH2( capturer ) catch(...) { capturer.useActiveException(); }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -62,8 +55,8 @@
|
|||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
catchAssertionHandler.handle( Catch::Decomposer() <= __VA_ARGS__ ); \
|
catchAssertionHandler.handle( Catch::Decomposer() <= __VA_ARGS__ ); \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
||||||
} INTERNAL_CATCH_CATCH2( catchAssertionHandler ) \
|
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::isTrue( false && static_cast<bool>( !!(__VA_ARGS__) ) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look
|
} while( Catch::isTrue( false && static_cast<bool>( !!(__VA_ARGS__) ) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look
|
||||||
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
|
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
|
||||||
|
|
||||||
@ -88,7 +81,7 @@
|
|||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
catchAssertionHandler.useActiveException(); \
|
catchAssertionHandler.useActiveException(); \
|
||||||
} \
|
} \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -105,7 +98,7 @@
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -125,7 +118,7 @@
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +127,7 @@
|
|||||||
do { \
|
do { \
|
||||||
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
|
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
|
||||||
catchAssertionHandler.handle( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str().c_str() ); \
|
catchAssertionHandler.handle( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str().c_str() ); \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -148,8 +141,8 @@
|
|||||||
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
||||||
INTERNAL_CATCH_TRY( catchAssertionHandler ) { \
|
INTERNAL_CATCH_TRY( catchAssertionHandler ) { \
|
||||||
catchAssertionHandler.handle( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \
|
catchAssertionHandler.handle( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \
|
||||||
} INTERNAL_CATCH_CATCH2( catchAssertionHandler ) \
|
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -166,7 +159,7 @@
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
|
|
||||||
|
|
||||||
@ -187,7 +180,7 @@
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
|
||||||
INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user