Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fixed inconsistency in reporting of _FALSE (negated) expressions

Commit
d4305377b78d81fa11281ac649ef2b67f6e417e5
Author
Phil Nash ·
Parents
374335fc84d2

Files · Download .tar.gz

Changes

 include/internal/catch_assertionresult.h        |  1 +
 include/internal/catch_assertionresult.hpp      | 16 +++++++++++-----
 include/reporters/catch_reporter_console.hpp    |  6 +-----
 projects/SelfTest/Baselines/approvedResults.txt | 24 ++++++++++++------------
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h
index b3f63e04..fb230adc 100644
--- a/include/internal/catch_assertionresult.h
+++ b/include/internal/catch_assertionresult.h
@@ -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;
diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp
index 5ba2f458..392270d8 100644
--- a/include/internal/catch_assertionresult.hpp
+++ b/include/internal/catch_assertionresult.hpp
@@ -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 {
diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index 99ba0bc3..658492a1 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -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";
                 }
             }
diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt
index bc909c9a..e676dfb1 100644
--- a/projects/SelfTest/Baselines/approvedResults.txt
+++ b/projects/SelfTest/Baselines/approvedResults.txt
@@ -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