diff --git a/include/catch.hpp b/include/catch.hpp index d51a24a2..1c330192 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -104,7 +104,7 @@ #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CHECK_FALSE" ) #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOFAIL" ) +#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" ) #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index c731c65d..37372b67 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -16,18 +16,15 @@ namespace Catch { struct AssertionInfo { AssertionInfo() {} - AssertionInfo( const std::string& _macroName, const SourceLineInfo& _lineInfo, const std::string& _capturedExpression = "", bool _shouldNegate = false ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ) - { - if( _shouldNegate ) - capturedExpression = "!" + _capturedExpression; - } + AssertionInfo( const std::string& _macroName, + const SourceLineInfo& _lineInfo, + const std::string& _capturedExpression, + ResultDisposition::Flags _resultDisposition ); std::string macroName; SourceLineInfo lineInfo; std::string capturedExpression; + ResultDisposition::Flags resultDisposition; }; struct AssertionResultData @@ -45,7 +42,8 @@ namespace Catch { AssertionResult( const AssertionInfo& info, const AssertionResultData& data ); ~AssertionResult(); - bool ok() const; + bool isOk() const; + bool succeeded() const; ResultWas::OfType getResultType() const; bool hasExpression() const; bool hasMessage() const; diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp index f1ef9d18..91853307 100644 --- a/include/internal/catch_assertionresult.hpp +++ b/include/internal/catch_assertionresult.hpp @@ -12,6 +12,20 @@ namespace Catch { + + AssertionInfo::AssertionInfo( const std::string& _macroName, + const SourceLineInfo& _lineInfo, + const std::string& _capturedExpression, + ResultDisposition::Flags _resultDisposition ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + capturedExpression( _capturedExpression ), + resultDisposition( _resultDisposition ) + { + if( shouldNegate( resultDisposition ) ) + capturedExpression = "!" + _capturedExpression; + } + AssertionResult::AssertionResult() {} AssertionResult::AssertionResult( const AssertionInfo& info, const AssertionResultData& data ) @@ -21,8 +35,14 @@ namespace Catch { AssertionResult::~AssertionResult() {} - bool AssertionResult::ok() const { - return isOk( m_resultData.resultType ); + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); } ResultWas::OfType AssertionResult::getResultType() const { diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 805d8179..e2919848 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -94,7 +94,7 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, resultDisposition ) \ - Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, testFlag( resultDisposition, Catch::ResultDisposition::NegateResult ) ); + Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, resultDisposition ); /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \ @@ -114,12 +114,12 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( Catch::getResultCapture().getLastResult()->ok() ) + if( Catch::getResultCapture().getLastResult()->succeeded() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( !Catch::getResultCapture().getLastResult()->ok() ) + if( !Catch::getResultCapture().getLastResult()->succeeded() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ diff --git a/include/internal/catch_expressionresult_builder.hpp b/include/internal/catch_expressionresult_builder.hpp index 1ecccad5..f0a8cccc 100644 --- a/include/internal/catch_expressionresult_builder.hpp +++ b/include/internal/catch_expressionresult_builder.hpp @@ -39,7 +39,7 @@ namespace Catch { return *this; } ExpressionResultBuilder& ExpressionResultBuilder::endExpression( ResultDisposition::Flags resultDisposition ) { - m_exprComponents.shouldNegate = testFlag( resultDisposition, ResultDisposition::NegateResult ); + m_exprComponents.shouldNegate = shouldNegate( resultDisposition ); return *this; } ExpressionResultBuilder& ExpressionResultBuilder::setLhs( const std::string& lhs ) { diff --git a/include/internal/catch_result_type.h b/include/internal/catch_result_type.h index 60678e27..051dde5f 100644 --- a/include/internal/catch_result_type.h +++ b/include/internal/catch_result_type.h @@ -57,6 +57,8 @@ namespace Catch { inline bool resetFlag( int flags, int bitOrBitsToReset ) { return static_cast( flags & ~bitOrBitsToReset ); } inline bool shouldContinueOnFailure( int flags ) { return testFlag( flags, ResultDisposition::ContinueOnFailure ); } + inline bool shouldNegate( int flags ) { return testFlag( flags, ResultDisposition::NegateResult ); } + inline bool shouldSuppressFailure( int flags ) { return testFlag( flags, ResultDisposition::SuppressFail ); } } // end namespace Catch diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index e581b909..f72d5768 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -139,7 +139,7 @@ namespace Catch { if( result.getResultType() == ResultWas::Ok ) { m_totals.assertions.passed++; } - else if( !result.ok() ) { + else if( !result.isOk() ) { m_totals.assertions.failed++; { @@ -235,7 +235,7 @@ namespace Catch { ResultAction::Value action = ResultAction::None; - if( !m_lastResult.ok() ) { + if( !m_lastResult.isOk() ) { action = ResultAction::Failed; if( shouldDebugBreak() ) action = (ResultAction::Value)( action | ResultAction::Debug ); @@ -247,7 +247,7 @@ namespace Catch { void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo() ); + m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal ); m_runningTest->reset(); Counts prevAssertions = m_totals.assertions; if( m_reporter->shouldRedirectStdout() ) { diff --git a/include/reporters/catch_reporter_basic.hpp b/include/reporters/catch_reporter_basic.hpp index 63074629..7a55d3be 100644 --- a/include/reporters/catch_reporter_basic.hpp +++ b/include/reporters/catch_reporter_basic.hpp @@ -173,13 +173,17 @@ namespace Catch { if( assertionResult.hasExpression() ) { TextColour colour( TextColour::OriginalExpression ); m_config.stream << assertionResult.getExpression(); - if( assertionResult.ok() ) { + if( assertionResult.succeeded() ) { TextColour successColour( TextColour::Success ); m_config.stream << " succeeded"; } else { TextColour errorColour( TextColour::Error ); m_config.stream << " failed"; + if( assertionResult.isOk() ) { + TextColour okAnywayColour( TextColour::Success ); + m_config.stream << " - but was ok"; + } } } switch( assertionResult.getResultType() ) { @@ -226,13 +230,17 @@ namespace Catch { case ResultWas::ExpressionFailed: case ResultWas::Exception: if( !assertionResult.hasExpression() ) { - if( assertionResult.ok() ) { + if( assertionResult.succeeded() ) { TextColour colour( TextColour::Success ); m_config.stream << " succeeded"; } else { TextColour colour( TextColour::Error ); m_config.stream << " failed"; + if( assertionResult.isOk() ) { + TextColour okAnywayColour( TextColour::Success ); + m_config.stream << " - but was ok"; + } } } break; diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index f2af6992..d2163dd3 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -81,7 +81,7 @@ namespace Catch { if( assertionResult.hasExpression() ) { m_xml.startElement( "Expression" ) - .writeAttribute( "success", assertionResult.ok() ) + .writeAttribute( "success", assertionResult.succeeded() ) .writeAttribute( "filename", assertionResult.getSourceInfo().file ) .writeAttribute( "line", assertionResult.getSourceInfo().line ); @@ -89,7 +89,7 @@ namespace Catch { .writeText( assertionResult.getExpression() ); m_xml.scopedElement( "Expanded" ) .writeText( assertionResult.getExpandedExpression() ); - m_currentTestSuccess &= assertionResult.ok(); + m_currentTestSuccess &= assertionResult.succeeded(); } switch( assertionResult.getResultType() ) { diff --git a/projects/SelfTest/Baselines/results.txt b/projects/SelfTest/Baselines/results.txt index d7b70545..8a15495d 100644 --- a/projects/SelfTest/Baselines/results.txt +++ b/projects/SelfTest/Baselines/results.txt @@ -189,12 +189,12 @@ [Running: ./succeeding/conditions/ptr] /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:271: p == __null succeeded for: __null == 0 /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:272: p == pNULL succeeded for: __null == __null -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:277: p != __null succeeded for: 0x7fff521a90a8 != 0 -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:280: cp != __null succeeded for: 0x7fff521a90a8 != 0 -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:283: cpc != __null succeeded for: 0x7fff521a90a8 != 0 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:277: p != __null succeeded for: 0x7fff50472078 != 0 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:280: cp != __null succeeded for: 0x7fff50472078 != 0 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:283: cpc != __null succeeded for: 0x7fff50472078 != 0 /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:285: returnsNull() == __null succeeded for: {null string} == 0 /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:286: returnsConstNull() == __null succeeded for: {null string} == 0 -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:288: __null != p succeeded for: 0 != 0x7fff521a90a8 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:288: __null != p succeeded for: 0 != 0x7fff50472078 [Finished: './succeeding/conditions/ptr' All tests passed (8 assertions in 1 test case)] [Running: ./succeeding/conditions/not] @@ -471,6 +471,10 @@ [Finished: './failing/message/sections' 1 test case failed (All 2 assertions failed)] +[Running: ./succeeding/nofail] +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/MessageTests.cpp:88: 1 == 2 failed - but was ok +[Finished: './succeeding/nofail' No tests ran] + [Running: ./succeeding/Misc/Sections] [Started section: 's1'] /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/MiscTests.cpp:25: a != b succeeded for: 1 != 2 @@ -575,7 +579,7 @@ [Finished: './succeeding/Tricky/std::pair' All tests passed (1 assertion in 1 test case)] [Running: ./failing/Tricky/non streamable type] -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff521a9878 == 0x7fff521a9870 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff50472858 == 0x7fff50472850 /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:96: o1 == o2 failed for: {?} == {?} [Finished: './failing/Tricky/non streamable type' 1 test case failed (All 2 assertions failed)] @@ -601,7 +605,7 @@ [Finished: './succeeding/enum/bits' All tests passed (1 assertion in 1 test case)] [Running: ./succeeding/boolean member] -/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff521a9870 != 0 +/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff50472850 != 0 [Finished: './succeeding/boolean member' All tests passed (1 assertion in 1 test case)] [Running: ./succeeding/unimplemented static bool] @@ -635,8 +639,8 @@ /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:314: !False succeeded for: true /Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:315: !False succeeded for: !false [Finished: './succeeding/SafeBool' All tests passed (3 assertions in 1 test case)] -[End of group: './failing* ./succeeding*'. 25 of 66 test cases failed (72 of 361 assertions failed)] +[End of group: './failing* ./succeeding*'. 25 of 67 test cases failed (72 of 361 assertions failed)] -[Testing completed. 25 of 66 test cases failed (72 of 361 assertions failed)] +[Testing completed. 25 of 67 test cases failed (72 of 361 assertions failed)] diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp index fe65f753..bcd52d71 100644 --- a/projects/SelfTest/MessageTests.cpp +++ b/projects/SelfTest/MessageTests.cpp @@ -82,3 +82,8 @@ TEST_CASE( "./mixed/message/scoped", "" ) REQUIRE( i < 10 ); } } + +TEST_CASE( "./succeeding/nofail", "The NO_FAIL macro reports a failure but does not fail the test" ) +{ + CHECK_NOFAIL( 1 == 2 ); +} diff --git a/single_include/catch.hpp b/single_include/catch.hpp index bb6ab776..3ba3e5a4 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,5 +1,5 @@ /* - * Generated: 2012-11-10 18:44:32.330710 + * Generated: 2012-11-12 19:04:30.724994 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -690,6 +690,8 @@ namespace Catch { inline bool resetFlag( int flags, int bitOrBitsToReset ) { return static_cast( flags & ~bitOrBitsToReset ); } inline bool shouldContinueOnFailure( int flags ) { return testFlag( flags, ResultDisposition::ContinueOnFailure ); } + inline bool shouldNegate( int flags ) { return testFlag( flags, ResultDisposition::NegateResult ); } + inline bool shouldSuppressFailure( int flags ) { return testFlag( flags, ResultDisposition::SuppressFail ); } } // end namespace Catch @@ -699,18 +701,15 @@ namespace Catch { struct AssertionInfo { AssertionInfo() {} - AssertionInfo( const std::string& _macroName, const SourceLineInfo& _lineInfo, const std::string& _capturedExpression = "", bool _shouldNegate = false ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ) - { - if( _shouldNegate ) - capturedExpression = "!" + _capturedExpression; - } + AssertionInfo( const std::string& _macroName, + const SourceLineInfo& _lineInfo, + const std::string& _capturedExpression, + ResultDisposition::Flags _resultDisposition ); std::string macroName; SourceLineInfo lineInfo; std::string capturedExpression; + ResultDisposition::Flags resultDisposition; }; struct AssertionResultData @@ -728,7 +727,8 @@ namespace Catch { AssertionResult( const AssertionInfo& info, const AssertionResultData& data ); ~AssertionResult(); - bool ok() const; + bool isOk() const; + bool succeeded() const; ResultWas::OfType getResultType() const; bool hasExpression() const; bool hasMessage() const; @@ -2085,7 +2085,7 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, resultDisposition ) \ - Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, testFlag( resultDisposition, Catch::ResultDisposition::NegateResult ) ); + Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, resultDisposition ); /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \ @@ -2105,12 +2105,12 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( Catch::getResultCapture().getLastResult()->ok() ) + if( Catch::getResultCapture().getLastResult()->succeeded() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( !Catch::getResultCapture().getLastResult()->ok() ) + if( !Catch::getResultCapture().getLastResult()->succeeded() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ @@ -4006,7 +4006,7 @@ namespace Catch { if( result.getResultType() == ResultWas::Ok ) { m_totals.assertions.passed++; } - else if( !result.ok() ) { + else if( !result.isOk() ) { m_totals.assertions.failed++; { @@ -4101,7 +4101,7 @@ namespace Catch { ResultAction::Value action = ResultAction::None; - if( !m_lastResult.ok() ) { + if( !m_lastResult.isOk() ) { action = ResultAction::Failed; if( shouldDebugBreak() ) action = (ResultAction::Value)( action | ResultAction::Debug ); @@ -4113,7 +4113,7 @@ namespace Catch { void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo() ); + m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal ); m_runningTest->reset(); Counts prevAssertions = m_totals.assertions; if( m_reporter->shouldRedirectStdout() ) { @@ -5083,6 +5083,19 @@ namespace Catch { namespace Catch { + AssertionInfo::AssertionInfo( const std::string& _macroName, + const SourceLineInfo& _lineInfo, + const std::string& _capturedExpression, + ResultDisposition::Flags _resultDisposition ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + capturedExpression( _capturedExpression ), + resultDisposition( _resultDisposition ) + { + if( shouldNegate( resultDisposition ) ) + capturedExpression = "!" + _capturedExpression; + } + AssertionResult::AssertionResult() {} AssertionResult::AssertionResult( const AssertionInfo& info, const AssertionResultData& data ) @@ -5092,8 +5105,14 @@ namespace Catch { AssertionResult::~AssertionResult() {} - bool AssertionResult::ok() const { - return isOk( m_resultData.resultType ); + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); } ResultWas::OfType AssertionResult::getResultType() const { @@ -5165,7 +5184,7 @@ namespace Catch { return *this; } ExpressionResultBuilder& ExpressionResultBuilder::endExpression( ResultDisposition::Flags resultDisposition ) { - m_exprComponents.shouldNegate = testFlag( resultDisposition, ResultDisposition::NegateResult ); + m_exprComponents.shouldNegate = shouldNegate( resultDisposition ); return *this; } ExpressionResultBuilder& ExpressionResultBuilder::setLhs( const std::string& lhs ) { @@ -5522,13 +5541,17 @@ namespace Catch { if( assertionResult.hasExpression() ) { TextColour colour( TextColour::OriginalExpression ); m_config.stream << assertionResult.getExpression(); - if( assertionResult.ok() ) { + if( assertionResult.succeeded() ) { TextColour successColour( TextColour::Success ); m_config.stream << " succeeded"; } else { TextColour errorColour( TextColour::Error ); m_config.stream << " failed"; + if( assertionResult.isOk() ) { + TextColour okAnywayColour( TextColour::Success ); + m_config.stream << " - but was ok"; + } } } switch( assertionResult.getResultType() ) { @@ -5575,13 +5598,17 @@ namespace Catch { case ResultWas::ExpressionFailed: case ResultWas::Exception: if( !assertionResult.hasExpression() ) { - if( assertionResult.ok() ) { + if( assertionResult.succeeded() ) { TextColour colour( TextColour::Success ); m_config.stream << " succeeded"; } else { TextColour colour( TextColour::Error ); m_config.stream << " failed"; + if( assertionResult.isOk() ) { + TextColour okAnywayColour( TextColour::Success ); + m_config.stream << " - but was ok"; + } } } break; @@ -5960,7 +5987,7 @@ namespace Catch { if( assertionResult.hasExpression() ) { m_xml.startElement( "Expression" ) - .writeAttribute( "success", assertionResult.ok() ) + .writeAttribute( "success", assertionResult.succeeded() ) .writeAttribute( "filename", assertionResult.getSourceInfo().file ) .writeAttribute( "line", assertionResult.getSourceInfo().line ); @@ -5968,7 +5995,7 @@ namespace Catch { .writeText( assertionResult.getExpression() ); m_xml.scopedElement( "Expanded" ) .writeText( assertionResult.getExpandedExpression() ); - m_currentTestSuccess &= assertionResult.ok(); + m_currentTestSuccess &= assertionResult.succeeded(); } switch( assertionResult.getResultType() ) { @@ -6381,7 +6408,7 @@ int main (int argc, char * const argv[]) { #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CHECK_FALSE" ) #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOFAIL" ) +#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" ) #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )