From da6c2a691477dc7e8cae4a783d1b16d6adb12b21 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 13 Oct 2017 19:44:20 +0100 Subject: [PATCH] Fixed expansion of _FALSE binary expression - see #1051 --- include/internal/catch_assertionresult.hpp | 2 +- .../Baselines/console.std.approved.txt | 4 ++-- .../Baselines/console.sw.approved.txt | 8 +++---- .../Baselines/console.swa4.approved.txt | 2 ++ .../SelfTest/Baselines/xml.sw.approved.txt | 22 +++++++++---------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp index 0a746b2f..116b2157 100644 --- a/include/internal/catch_assertionresult.hpp +++ b/include/internal/catch_assertionresult.hpp @@ -66,7 +66,7 @@ namespace Catch { std::string AssertionResult::getExpression() const { if( isFalseTest( m_info.resultDisposition ) ) - return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); + return "!(" + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + ")"; else return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); } diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 21818733..910155ce 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -58,6 +58,8 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) +with expansion: + !true ConditionTests.cpp:: FAILED: CHECK( !trueValue ) @@ -76,8 +78,6 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( 1 == 1 ) -with expansion: - !(1 == 1) ------------------------------------------------------------------------------- A METHOD_AS_TEST_CASE based test run that fails diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 4288952c..c3b0499d 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -202,6 +202,8 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) +with expansion: + !true ConditionTests.cpp:: FAILED: CHECK( !trueValue ) @@ -220,8 +222,6 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( 1 == 1 ) -with expansion: - !(1 == 1) ------------------------------------------------------------------------------- 'Not' checks that should succeed @@ -246,6 +246,8 @@ with expansion: ConditionTests.cpp:: PASSED: REQUIRE_FALSE( false ) +with expansion: + !false ConditionTests.cpp:: PASSED: @@ -268,8 +270,6 @@ with expansion: ConditionTests.cpp:: PASSED: REQUIRE_FALSE( 1 == 2 ) -with expansion: - !(1 == 2) ------------------------------------------------------------------------------- (unimplemented) static bools can be evaluated diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index 0e0380bb..a831b8b5 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -202,6 +202,8 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) +with expansion: + !true =============================================================================== test cases: 7 | 4 passed | 1 failed | 2 failed as expected diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index fe712c73..6322993f 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -181,7 +181,7 @@ - !true + !(true) !true @@ -197,7 +197,7 @@ - !trueValue + !(trueValue) !true @@ -213,7 +213,7 @@ - !1 == 1 + !(1 == 1) !(1 == 1) @@ -248,7 +248,7 @@ - !false + !(false) !false @@ -264,7 +264,7 @@ - !falseValue + !(falseValue) !false @@ -280,7 +280,7 @@ - !1 == 2 + !(1 == 2) !(1 == 2) @@ -360,7 +360,7 @@ - !is_true<false>::value + !(is_true<false>::value) !false @@ -2708,7 +2708,7 @@ - !d >= Approx( 1.24 ) + !(d >= Approx( 1.24 )) !(1.23 >= Approx( 1.24 )) @@ -2968,7 +2968,7 @@ - !d <= Approx( 1.22 ) + !(d <= Approx( 1.22 )) !(1.23 <= Approx( 1.22 )) @@ -4726,7 +4726,7 @@ re>" - !False + !(False) !0 @@ -9709,7 +9709,7 @@ spanner
- !replaceInPlace( letters, "x", "z" ) + !(replaceInPlace( letters, "x", "z" )) !false