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 hasMessage() const;
std::string getExpression() const;
std::string getExpressionInMacro() const;
bool hasExpandedExpression() const;
std::string getExpandedExpression() const;
std::string getMessage() const;

View File

@ -21,10 +21,7 @@ namespace Catch {
lineInfo( _lineInfo ),
capturedExpression( _capturedExpression ),
resultDisposition( _resultDisposition )
{
if( shouldNegate( resultDisposition ) )
capturedExpression = "!" + _capturedExpression;
}
{}
AssertionResult::AssertionResult() {}
@ -58,7 +55,16 @@ namespace Catch {
}
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 {

View File

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

View File

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