Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2017-08-08 19:43:07 +0100
committerPhil Nash2017-08-08 19:43:07 +0100
commit8a97beece21ac02ba71b03fe33f5ccaba36ff4c0 (patch)
tree3b496a1f6eac98f478fcfdb41c0457e0eaa183dd /include
parentf033f4f1842cb3859b97855261d3119488783b20 (diff)
downloadcatch3-8a97beece21ac02ba71b03fe33f5ccaba36ff4c0.tar.gz
integrated AssertionHandler into INTERNAL_CATCH_THROWS_AS
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_assertionhandler.cpp3
-rw-r--r--include/internal/catch_assertionhandler.h1
-rw-r--r--include/internal/catch_capture.hpp14
3 files changed, 11 insertions, 7 deletions
diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp
index 1b7e1346..fe8e32a0 100644
--- a/include/internal/catch_assertionhandler.cpp
+++ b/include/internal/catch_assertionhandler.cpp
@@ -90,6 +90,9 @@ namespace Catch {
void AssertionHandler::handle( ResultWas::OfType resultType ) {
handle( resultType, nullptr, false );
}
+ auto AssertionHandler::allowThrows() const -> bool {
+ return getCurrentContext().getConfig()->allowThrows();
+ }
auto AssertionHandler::shouldDebugBreak() const -> bool {
return m_shouldDebugBreak;
diff --git a/include/internal/catch_assertionhandler.h b/include/internal/catch_assertionhandler.h
index 0c8b020b..6e140e44 100644
--- a/include/internal/catch_assertionhandler.h
+++ b/include/internal/catch_assertionhandler.h
@@ -54,6 +54,7 @@ namespace Catch {
void handle( AssertionResultData const& resultData, ITransientExpression const* expr );
auto shouldDebugBreak() const -> bool;
+ auto allowThrows() const -> bool;
void reactWithDebugBreak() const;
void reactWithoutDebugBreak() const;
void useActiveException( ResultDisposition::Flags resultDisposition );
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 9510d7a5..68859412 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -112,21 +112,21 @@
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
- if( __catchResult.allowThrows() ) \
+ Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
+ if( catchAssertionHandler.allowThrows() ) \
try { \
static_cast<void>(expr); \
- __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
+ catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \
} \
catch( exceptionType const& ) { \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
+ catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
} \
catch( ... ) { \
- __catchResult.useActiveException( resultDisposition ); \
+ catchAssertionHandler.useActiveException(); \
} \
else \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
- INTERNAL_CATCH_REACT( __catchResult ) \
+ catchAssertionHandler.handle( Catch::ResultWas::Ok ); \
+ INTERNAL_CATCH_REACT2( catchAssertionHandler ) \
} while( Catch::alwaysFalse() )