diff options
| author | Phil Nash | 2017-08-08 20:17:09 +0100 |
|---|---|---|
| committer | Phil Nash | 2017-08-08 20:17:09 +0100 |
| commit | 5f9172436883c535de4a119bd3b2314a2a5f9f70 (patch) | |
| tree | 2d269fc614eb3418e8100fa4bfd636fef6149edb /include/internal/catch_assertionhandler.cpp | |
| parent | 8a97beece21ac02ba71b03fe33f5ccaba36ff4c0 (diff) | |
| download | catch3-5f9172436883c535de4a119bd3b2314a2a5f9f70.tar.gz | |
integrated AssertionHandler into INTERNAL_CATCH_MSG
Diffstat (limited to 'include/internal/catch_assertionhandler.cpp')
| -rw-r--r-- | include/internal/catch_assertionhandler.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp index fe8e32a0..d53b09fa 100644 --- a/include/internal/catch_assertionhandler.cpp +++ b/include/internal/catch_assertionhandler.cpp @@ -59,8 +59,22 @@ namespace Catch { getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo ); } - void AssertionHandler::handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ) { + void AssertionHandler::handle( ITransientExpression const& expr ) { + bool negated = isFalseTest( m_assertionInfo.resultDisposition ); + bool result = expr.getResult() != negated; + + handle( result ? ResultWas::Ok : ResultWas::ExpressionFailed, &expr, negated ); + } + void AssertionHandler::handle( ResultWas::OfType resultType ) { + handle( resultType, nullptr, false ); + } + void AssertionHandler::handle( ResultWas::OfType resultType, StringRef const& message ) { + AssertionResultData data( resultType, LazyExpression( false ) ); + data.message = message.c_str(); + handle( data, nullptr ); + } + void AssertionHandler::handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ) { AssertionResultData data( resultType, LazyExpression( negated ) ); handle( data, expr ); } @@ -80,16 +94,7 @@ namespace Catch { (m_assertionInfo.resultDisposition & ResultDisposition::Normal); } } - void AssertionHandler::handle( ITransientExpression const& expr ) { - - bool negated = isFalseTest( m_assertionInfo.resultDisposition ); - bool result = expr.getResult() != negated; - handle( result ? ResultWas::Ok : ResultWas::ExpressionFailed, &expr, negated ); - } - void AssertionHandler::handle( ResultWas::OfType resultType ) { - handle( resultType, nullptr, false ); - } auto AssertionHandler::allowThrows() const -> bool { return getCurrentContext().getConfig()->allowThrows(); } @@ -117,12 +122,7 @@ namespace Catch { useActiveException(); } void AssertionHandler::useActiveException() { - bool negated = isFalseTest( m_assertionInfo.resultDisposition ); - - AssertionResultData data( ResultWas::ThrewException, LazyExpression( negated ) ); - data.message = Catch::translateActiveException(); - - handle( data, nullptr ); + handle( ResultWas::ThrewException, Catch::translateActiveException().c_str() ); } } // namespace Catch |