From 05b1ca28844d2b2770b929415393653474866a3d Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 13 Oct 2017 19:45:19 +0100 Subject: [PATCH] Fixed expansion of _FALSE binary expression - see #1051 --- include/internal/catch_assertionresult.cpp | 4 +-- .../Baselines/console.std.approved.txt | 4 +-- .../Baselines/console.sw.approved.txt | 8 +++--- .../Baselines/console.swa4.approved.txt | 2 ++ .../SelfTest/Baselines/xml.sw.approved.txt | 26 +++++++++---------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp index 7a3a2e08..3af40dfc 100644 --- a/include/internal/catch_assertionresult.cpp +++ b/include/internal/catch_assertionresult.cpp @@ -54,8 +54,8 @@ namespace Catch { } std::string AssertionResult::getExpression() const { - if (isFalseTest(m_info.resultDisposition)) - return '!' + std::string(m_info.capturedExpression); + if( isFalseTest( m_info.resultDisposition ) ) + return "!(" + std::string(m_info.capturedExpression) + ")"; else return m_info.capturedExpression; } diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 939d0d89..cc23a7dd 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 1d64df20..e32d6f72 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -235,6 +235,8 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) +with expansion: + !true ConditionTests.cpp:: FAILED: CHECK( !trueValue ) @@ -253,8 +255,6 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( 1 == 1 ) -with expansion: - !(1 == 1) ------------------------------------------------------------------------------- 'Not' checks that should succeed @@ -279,6 +279,8 @@ with expansion: ConditionTests.cpp:: PASSED: REQUIRE_FALSE( false ) +with expansion: + !false ConditionTests.cpp:: PASSED: @@ -301,8 +303,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 06c24e86..eacf34e1 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -235,6 +235,8 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK_FALSE( true ) +with expansion: + !true =============================================================================== test cases: 9 | 6 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 72b7c1b6..04c6f986 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -214,7 +214,7 @@ - !true + !(true) !true @@ -230,7 +230,7 @@ - !trueValue + !(trueValue) !true @@ -246,7 +246,7 @@ - !1 == 1 + !(1 == 1) !(1 == 1) @@ -281,7 +281,7 @@ - !false + !(false) !false @@ -297,7 +297,7 @@ - !falseValue + !(falseValue) !false @@ -313,7 +313,7 @@ - !1 == 2 + !(1 == 2) !(1 == 2) @@ -393,7 +393,7 @@ - !is_true<false>::value + !(is_true<false>::value) !false @@ -975,7 +975,7 @@ - !std::vector<int>{1, 2} == std::vector<int>{1, 2, 3} + !(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}) !({ 1, 2 } == { 1, 2, 3 }) @@ -983,7 +983,7 @@ - !std::vector<int>{1, 2} == std::vector<int>{1, 2, 3} + !(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}) !({ 1, 2 } == { 1, 2, 3 }) @@ -1813,7 +1813,7 @@ - !d >= Approx( 1.24 ) + !(d >= Approx( 1.24 )) !(1.23 >= Approx( 1.24 )) @@ -2230,7 +2230,7 @@ - !d <= Approx( 1.22 ) + !(d <= Approx( 1.22 )) !(1.23 <= Approx( 1.22 )) @@ -2373,7 +2373,7 @@ - !False + !(False) !{?} @@ -7633,7 +7633,7 @@ loose text artifact
- !Catch::replaceInPlace( letters, "x", "z" ) + !(Catch::replaceInPlace( letters, "x", "z" )) !false