Fixed inconsistency in reporting of _FALSE (negated) expressions

This commit is contained in:
Phil Nash 2013-05-17 19:35:33 +01:00
parent 374335fc84
commit d4305377b7
4 changed files with 25 additions and 22 deletions

View File

@ -48,6 +48,7 @@ namespace Catch {
bool hasExpression() const; bool hasExpression() const;
bool hasMessage() const; bool hasMessage() const;
std::string getExpression() const; std::string getExpression() const;
std::string getExpressionInMacro() const;
bool hasExpandedExpression() const; bool hasExpandedExpression() const;
std::string getExpandedExpression() const; std::string getExpandedExpression() const;
std::string getMessage() const; std::string getMessage() const;

View File

@ -21,10 +21,7 @@ namespace Catch {
lineInfo( _lineInfo ), lineInfo( _lineInfo ),
capturedExpression( _capturedExpression ), capturedExpression( _capturedExpression ),
resultDisposition( _resultDisposition ) resultDisposition( _resultDisposition )
{ {}
if( shouldNegate( resultDisposition ) )
capturedExpression = "!" + _capturedExpression;
}
AssertionResult::AssertionResult() {} AssertionResult::AssertionResult() {}
@ -58,7 +55,16 @@ namespace Catch {
} }
std::string AssertionResult::getExpression() const { std::string AssertionResult::getExpression() const {
return m_info.capturedExpression; if( shouldNegate( m_info.resultDisposition ) )
return "!" + m_info.capturedExpression;
else
return m_info.capturedExpression;
}
std::string AssertionResult::getExpressionInMacro() const {
if( m_info.macroName.empty() )
return m_info.capturedExpression;
else
return m_info.macroName + "( " + m_info.capturedExpression + " )";
} }
bool AssertionResult::hasExpandedExpression() const { bool AssertionResult::hasExpandedExpression() const {

View File

@ -191,11 +191,7 @@ namespace Catch {
if( result.hasExpression() ) { if( result.hasExpression() ) {
Colour colourGuard( Colour::OriginalExpression ); Colour colourGuard( Colour::OriginalExpression );
stream << " "; stream << " ";
if( !result.getTestMacroName().empty() ) stream << result.getExpressionInMacro();
stream << result.getTestMacroName() << "( ";
stream << result.getExpression();
if( !result.getTestMacroName().empty() )
stream << " )";
stream << "\n"; stream << "\n";
} }
} }

View File

@ -954,7 +954,7 @@ with expansion:
ConditionTests.cpp:323: ConditionTests.cpp:323:
PASSED: PASSED:
REQUIRE_FALSE( !false ) REQUIRE_FALSE( false )
ConditionTests.cpp:325: ConditionTests.cpp:325:
PASSED: PASSED:
@ -964,7 +964,7 @@ with expansion:
ConditionTests.cpp:326: ConditionTests.cpp:326:
PASSED: PASSED:
REQUIRE_FALSE( !falseValue ) REQUIRE_FALSE( falseValue )
with expansion: with expansion:
!false !false
@ -976,7 +976,7 @@ with expansion:
ConditionTests.cpp:329: ConditionTests.cpp:329:
PASSED: PASSED:
REQUIRE_FALSE( !1 == 2 ) REQUIRE_FALSE( 1 == 2 )
with expansion: with expansion:
!(1 == 2) !(1 == 2)
@ -998,7 +998,7 @@ with expansion:
false false
ConditionTests.cpp:340: FAILED: ConditionTests.cpp:340: FAILED:
CHECK_FALSE( !true ) CHECK_FALSE( true )
ConditionTests.cpp:342: FAILED: ConditionTests.cpp:342: FAILED:
CHECK( !trueValue ) CHECK( !trueValue )
@ -1006,7 +1006,7 @@ with expansion:
false false
ConditionTests.cpp:343: FAILED: ConditionTests.cpp:343: FAILED:
CHECK_FALSE( !trueValue ) CHECK_FALSE( trueValue )
with expansion: with expansion:
!true !true
@ -1016,7 +1016,7 @@ with expansion:
false false
ConditionTests.cpp:346: FAILED: ConditionTests.cpp:346: FAILED:
CHECK_FALSE( !1 == 1 ) CHECK_FALSE( 1 == 1 )
with expansion: with expansion:
!(1 == 1) !(1 == 1)
@ -5169,7 +5169,7 @@ with expansion:
TrickyTests.cpp:281: TrickyTests.cpp:281:
PASSED: PASSED:
REQUIRE_FALSE( !is_true<false>::value ) REQUIRE_FALSE( is_true<false>::value )
with expansion: with expansion:
!false !false
@ -5193,7 +5193,7 @@ with expansion:
TrickyTests.cpp:315: TrickyTests.cpp:315:
PASSED: PASSED:
CHECK_FALSE( !False ) CHECK_FALSE( False )
with expansion: with expansion:
!false !false
@ -5639,7 +5639,7 @@ with expansion:
CmdLineTests.cpp:475: CmdLineTests.cpp:475:
PASSED: PASSED:
REQUIRE_FALSE( !unusedTokens.empty() ) REQUIRE_FALSE( unusedTokens.empty() )
with expansion: with expansion:
!false !false
@ -5739,19 +5739,19 @@ CmdLineTests.cpp:633
CmdLineTests.cpp:635: CmdLineTests.cpp:635:
PASSED: PASSED:
CHECK_FALSE( !config.showPassingTests ) CHECK_FALSE( config.showPassingTests )
with expansion: with expansion:
!false !false
CmdLineTests.cpp:636: CmdLineTests.cpp:636:
PASSED: PASSED:
CHECK_FALSE( !config.noThrow ) CHECK_FALSE( config.noThrow )
with expansion: with expansion:
!false !false
CmdLineTests.cpp:637: CmdLineTests.cpp:637:
PASSED: PASSED:
CHECK_FALSE( !config.breakIntoDebugger ) CHECK_FALSE( config.breakIntoDebugger )
with expansion: with expansion:
!false !false