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

Add test for #914 (stringify truthy exprs in standard way)

Commit
ea48ae0f753121476b525584744c236dc22d73db
Author
Martin Hořeňovský ·
Parents
2d1739b42962

Files · Download .tar.gz

Changes

 CMakeLists.txt                                     |  1 +
 .../SelfTest/Baselines/console.std.approved.txt    | 15 ++++++++++--
 .../SelfTest/Baselines/console.sw.approved.txt     | 21 ++++++++++++----
 projects/SelfTest/Baselines/junit.sw.approved.txt  |  7 +++++-
 projects/SelfTest/Baselines/xml.sw.approved.txt    | 21 ++++++++++++----
 projects/SelfTest/DecompositionTests.cpp           | 28 ++++++++++++++++++++++
 6 files changed, 80 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0bd7dd1f..6e608fa3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,7 @@ set(TEST_SOURCES
         ${SELF_TEST_DIR}/CmdLineTests.cpp
         ${SELF_TEST_DIR}/CompilationTests.cpp
         ${SELF_TEST_DIR}/ConditionTests.cpp
+        ${SELF_TEST_DIR}/DecompositionTests.cpp
         ${SELF_TEST_DIR}/EnumToString.cpp
         ${SELF_TEST_DIR}/ExceptionTests.cpp
         ${SELF_TEST_DIR}/GeneratorTests.cpp
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index 0ad362e9..19e545ba 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -595,6 +595,17 @@ MessageTests.cpp:<line number>:
 warning:
   toString(p): 0x<hex digits>
 
+-------------------------------------------------------------------------------
+Reconstruction should be based on stringification: #914
+-------------------------------------------------------------------------------
+DecompositionTests.cpp:<line number>
+...............................................................................
+
+DecompositionTests.cpp:<line number>: FAILED:
+  CHECK( truthy(false) )
+with expansion:
+  Hey, its truthy!
+
 -------------------------------------------------------------------------------
 SCOPED_INFO is reset for each loop
 -------------------------------------------------------------------------------
@@ -942,6 +953,6 @@ with expansion:
   "first" == "second"
 
 ===============================================================================
-test cases: 167 | 119 passed | 44 failed |  4 failed as expected
-assertions: 967 | 859 passed | 87 failed | 21 failed as expected
+test cases: 168 | 119 passed | 45 failed |  4 failed as expected
+assertions: 968 | 859 passed | 88 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index c1d8865a..cdc414a4 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -819,7 +819,7 @@ TrickyTests.cpp:<line number>:
 PASSED:
   REQUIRE( a )
 with expansion:
-  true
+  0x<hex digits>
 
 TrickyTests.cpp:<line number>:
 PASSED:
@@ -4571,7 +4571,7 @@ TrickyTests.cpp:<line number>:
 PASSED:
   CHECK( True )
 with expansion:
-  true
+  1
 
 TrickyTests.cpp:<line number>:
 PASSED:
@@ -4583,7 +4583,7 @@ TrickyTests.cpp:<line number>:
 PASSED:
   CHECK_FALSE( False )
 with expansion:
-  !false
+  !0
 
 -------------------------------------------------------------------------------
 Operators at different namespace levels not hijacked by Koenig lookup
@@ -6437,6 +6437,17 @@ TestMain.cpp:<line number>:
 PASSED:
   REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) )
 
+-------------------------------------------------------------------------------
+Reconstruction should be based on stringification: #914
+-------------------------------------------------------------------------------
+DecompositionTests.cpp:<line number>
+...............................................................................
+
+DecompositionTests.cpp:<line number>: FAILED:
+  CHECK( truthy(false) )
+with expansion:
+  Hey, its truthy!
+
 -------------------------------------------------------------------------------
 SCOPED_INFO is reset for each loop
 -------------------------------------------------------------------------------
@@ -9472,6 +9483,6 @@ MiscTests.cpp:<line number>:
 PASSED:
 
 ===============================================================================
-test cases: 167 | 118 passed | 45 failed |  4 failed as expected
-assertions: 969 | 859 passed | 89 failed | 21 failed as expected
+test cases: 168 | 118 passed | 46 failed |  4 failed as expected
+assertions: 970 | 859 passed | 90 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 6237fb63..b723f207 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuitesspanner>
-  <testsuite name="<exe-name>" errors="13" failures="77" tests="970" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="13" failures="78" tests="971" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
     <testcase classname="#748 - captures with unexpected exceptions" name="outside assertions" time="{duration}">
       <error type="TEST_CASE">
@@ -443,6 +443,11 @@ MessageTests.cpp:<line number>
     <testcase classname="Process can be configured on command line" name="use-colour/yes" time="{duration}"/>
     <testcase classname="Process can be configured on command line" name="use-colour/no" time="{duration}"/>
     <testcase classname="Process can be configured on command line" name="use-colour/error" time="{duration}"/>
+    <testcase classname="global" name="Reconstruction should be based on stringification: #914" time="{duration}">
+      <failure message="Hey, its truthy!" type="CHECK">
+DecompositionTests.cpp:<line number>
+      </failure>
+    </testcase>
     <testcase classname="global" name="SCOPED_INFO is reset for each loop" time="{duration}">
       <failure message="10 &lt; 10" type="REQUIRE">
 current counter 10
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 83d9a421..6361fee3 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -890,7 +890,7 @@
           a
         </Original>
         <Expanded>
-          true
+          0x<hex digits>
         </Expanded>
       </Expression>
       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/TrickyTests.cpp" >
@@ -4695,7 +4695,7 @@ re>"
           True
         </Original>
         <Expanded>
-          true
+          1
         </Expanded>
       </Expression>
       <Expression success="true" type="CHECK" filename="projects/<exe-name>/TrickyTests.cpp" >
@@ -4711,7 +4711,7 @@ re>"
           !False
         </Original>
         <Expanded>
-          !false
+          !0
         </Expanded>
       </Expression>
       <OverallResult success="true"/>
@@ -6912,6 +6912,17 @@ re>"
       </Section>
       <OverallResult success="true"/>
     </TestCase>
+    <TestCase name="Reconstruction should be based on stringification: #914" tags="[.][Decomposition][failing][hide]" filename="projects/<exe-name>/DecompositionTests.cpp" >
+      <Expression success="false" type="CHECK" filename="projects/<exe-name>/DecompositionTests.cpp" >
+        <Original>
+          truthy(false)
+        </Original>
+        <Expanded>
+          Hey, its truthy!
+        </Expanded>
+      </Expression>
+      <OverallResult success="false"/>
+    </TestCase>
     <TestCase name="SCOPED_INFO is reset for each loop" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
       <Info>
         current counter 0
@@ -10132,7 +10143,7 @@ spanner      <OverallResult success="true"/>
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="859" failures="90" expectedFailures="21"/>
+    <OverallResults successes="859" failures="91" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="859" failures="89" expectedFailures="21"/>
+  <OverallResults successes="859" failures="90" expectedFailures="21"/>
 </Catch>
diff --git a/projects/SelfTest/DecompositionTests.cpp b/projects/SelfTest/DecompositionTests.cpp
new file mode 100644
index 00000000..f2e04260
--- /dev/null
+++ b/projects/SelfTest/DecompositionTests.cpp
@@ -0,0 +1,28 @@
+/*
+ *  Created by Martin on 27/5/2017.
+ *  Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
+ *
+ *  Distributed under the Boost Software License, Version 1.0. (See accompanying
+ *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <iostream>
+
+struct truthy {
+    truthy(bool b):m_value(b){}
+    operator bool() const {
+        return false;
+    }
+    bool m_value;
+};
+
+std::ostream& operator<<(std::ostream& o, truthy) {
+    o << "Hey, its truthy!";
+    return o;
+}
+
+#include "catch.hpp"
+
+TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") {
+    CHECK(truthy(false));
+}