diff options
| author | Phil Nash | 2017-08-08 19:36:18 +0100 |
|---|---|---|
| committer | Phil Nash | 2017-08-08 19:36:18 +0100 |
| commit | f033f4f1842cb3859b97855261d3119488783b20 (patch) | |
| tree | f7a73353080ffcae9f43531e1ce84fe4d3ab429d /include/internal/catch_assertionhandler.cpp | |
| parent | f247ce5bff025281d4a7e9fa76aa78eb8479ddfe (diff) | |
| download | catch3-f033f4f1842cb3859b97855261d3119488783b20.tar.gz | |
integrated AssertionHandler into INTERNAL_CATCH_NO_THROW
Diffstat (limited to 'include/internal/catch_assertionhandler.cpp')
| -rw-r--r-- | include/internal/catch_assertionhandler.cpp | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp index a71a2dc2..1b7e1346 100644 --- a/include/internal/catch_assertionhandler.cpp +++ b/include/internal/catch_assertionhandler.cpp @@ -59,24 +59,17 @@ namespace Catch { getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo ); } - void AssertionHandler::handle( ITransientExpression const& expr ) { - - bool negated = isFalseTest( m_assertionInfo.resultDisposition ); - bool result = expr.getResult() != negated; - - AssertionResultData data( result ? ResultWas::Ok : ResultWas::ExpressionFailed, LazyExpression( negated ) ); - - // Deprecated -// data.negated = negated; -// data.parenthesized = negated && expr.isBinaryExpression(); // !TBD: needed? -// data.decomposedExpression = nullptr; // !TBD -// data.reconstructedExpression = ""; // !TBD + void AssertionHandler::handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ) { + AssertionResultData data( resultType, LazyExpression( negated ) ); + handle( data, expr ); + } + void AssertionHandler::handle( AssertionResultData const& resultData, ITransientExpression const* expr ) { getResultCapture().assertionRun(); - AssertionResult assertionResult{ m_assertionInfo, data }; - assertionResult.m_resultData.lazyExpression.m_transientExpression = &expr; + AssertionResult assertionResult{ m_assertionInfo, resultData }; + assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; getResultCapture().assertionEnded( assertionResult ); @@ -87,6 +80,16 @@ 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::shouldDebugBreak() const -> bool { return m_shouldDebugBreak; @@ -116,20 +119,7 @@ namespace Catch { AssertionResultData data( ResultWas::ThrewException, LazyExpression( negated ) ); data.message = Catch::translateActiveException(); - //data.decomposedExpression = &expr; // for lazy reconstruction - - AssertionResult result( m_assertionInfo, data ); - - getResultCapture().assertionEnded( result ); - - // !TBD: factor this out? handleResult()? - if( !result.isOk() ) { - if( getCurrentContext().getConfig()->shouldDebugBreak() ) - m_shouldDebugBreak = true; - if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) ) - m_shouldThrow = true; - } - + handle( data, nullptr ); } } // namespace Catch |