Fixed expansion of _FALSE binary expression

- see #1051
This commit is contained in:
Phil Nash 2017-10-13 19:45:19 +01:00
parent c2b7bd15c0
commit 05b1ca2884
5 changed files with 23 additions and 21 deletions

View File

@ -54,8 +54,8 @@ namespace Catch {
} }
std::string AssertionResult::getExpression() const { std::string AssertionResult::getExpression() const {
if (isFalseTest(m_info.resultDisposition)) if( isFalseTest( m_info.resultDisposition ) )
return '!' + std::string(m_info.capturedExpression); return "!(" + std::string(m_info.capturedExpression) + ")";
else else
return m_info.capturedExpression; return m_info.capturedExpression;
} }

View File

@ -58,6 +58,8 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK_FALSE( true ) CHECK_FALSE( true )
with expansion:
!true
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK( !trueValue ) CHECK( !trueValue )
@ -76,8 +78,6 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK_FALSE( 1 == 1 ) CHECK_FALSE( 1 == 1 )
with expansion:
!(1 == 1)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
A METHOD_AS_TEST_CASE based test run that fails A METHOD_AS_TEST_CASE based test run that fails

View File

@ -235,6 +235,8 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK_FALSE( true ) CHECK_FALSE( true )
with expansion:
!true
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK( !trueValue ) CHECK( !trueValue )
@ -253,8 +255,6 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK_FALSE( 1 == 1 ) CHECK_FALSE( 1 == 1 )
with expansion:
!(1 == 1)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
'Not' checks that should succeed 'Not' checks that should succeed
@ -279,6 +279,8 @@ with expansion:
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_FALSE( false ) REQUIRE_FALSE( false )
with expansion:
!false
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
@ -301,8 +303,6 @@ with expansion:
ConditionTests.cpp:<line number>: ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_FALSE( 1 == 2 ) REQUIRE_FALSE( 1 == 2 )
with expansion:
!(1 == 2)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
(unimplemented) static bools can be evaluated (unimplemented) static bools can be evaluated

View File

@ -235,6 +235,8 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED: ConditionTests.cpp:<line number>: FAILED:
CHECK_FALSE( true ) CHECK_FALSE( true )
with expansion:
!true
=============================================================================== ===============================================================================
test cases: 9 | 6 passed | 1 failed | 2 failed as expected test cases: 9 | 6 passed | 1 failed | 2 failed as expected

View File

@ -214,7 +214,7 @@
</Expression> </Expression>
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!true !(true)
</Original> </Original>
<Expanded> <Expanded>
!true !true
@ -230,7 +230,7 @@
</Expression> </Expression>
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!trueValue !(trueValue)
</Original> </Original>
<Expanded> <Expanded>
!true !true
@ -246,7 +246,7 @@
</Expression> </Expression>
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!1 == 1 !(1 == 1)
</Original> </Original>
<Expanded> <Expanded>
!(1 == 1) !(1 == 1)
@ -281,7 +281,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!false !(false)
</Original> </Original>
<Expanded> <Expanded>
!false !false
@ -297,7 +297,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!falseValue !(falseValue)
</Original> </Original>
<Expanded> <Expanded>
!false !false
@ -313,7 +313,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
<Original> <Original>
!1 == 2 !(1 == 2)
</Original> </Original>
<Expanded> <Expanded>
!(1 == 2) !(1 == 2)
@ -393,7 +393,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
<Original> <Original>
!is_true&lt;false>::value !(is_true&lt;false>::value)
</Original> </Original>
<Expanded> <Expanded>
!false !false
@ -975,7 +975,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
<Original> <Original>
!std::vector&lt;int>{1, 2} == std::vector&lt;int>{1, 2, 3} !(std::vector&lt;int>{1, 2} == std::vector&lt;int>{1, 2, 3})
</Original> </Original>
<Expanded> <Expanded>
!({ 1, 2 } == { 1, 2, 3 }) !({ 1, 2 } == { 1, 2, 3 })
@ -983,7 +983,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" > <Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
<Original> <Original>
!std::vector&lt;int>{1, 2} == std::vector&lt;int>{1, 2, 3} !(std::vector&lt;int>{1, 2} == std::vector&lt;int>{1, 2, 3})
</Original> </Original>
<Expanded> <Expanded>
!({ 1, 2 } == { 1, 2, 3 }) !({ 1, 2 } == { 1, 2, 3 })
@ -1813,7 +1813,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
<Original> <Original>
!d >= Approx( 1.24 ) !(d >= Approx( 1.24 ))
</Original> </Original>
<Expanded> <Expanded>
!(1.23 >= Approx( 1.24 )) !(1.23 >= Approx( 1.24 ))
@ -2230,7 +2230,7 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" > <Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
<Original> <Original>
!d &lt;= Approx( 1.22 ) !(d &lt;= Approx( 1.22 ))
</Original> </Original>
<Expanded> <Expanded>
!(1.23 &lt;= Approx( 1.22 )) !(1.23 &lt;= Approx( 1.22 ))
@ -2373,7 +2373,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" > <Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
<Original> <Original>
!False !(False)
</Original> </Original>
<Expanded> <Expanded>
!{?} !{?}
@ -7633,7 +7633,7 @@ loose text artifact
<Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" > <Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" > <Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" >
<Original> <Original>
!Catch::replaceInPlace( letters, "x", "z" ) !(Catch::replaceInPlace( letters, "x", "z" ))
</Original> </Original>
<Expanded> <Expanded>
!false !false