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

Refactor how shortcircuiting of old style matchers is tested

Commit
5ca68829e10cc28471d2340439b53a41e8ff4e63
Author
Martin Hořeňovský ·
Parents
ac54ba7e12b7

Files · Download .tar.gz

Changes

 tests/SelfTest/Baselines/compact.sw.approved.txt   |  4 ++--
 tests/SelfTest/Baselines/console.sw.approved.txt   | 14 ++++++--------
 tests/SelfTest/Baselines/junit.sw.approved.txt     |  4 ++--
 tests/SelfTest/Baselines/sonarqube.sw.approved.txt |  4 ++--
 tests/SelfTest/Baselines/tap.sw.approved.txt       |  4 ++--
 tests/SelfTest/Baselines/xml.sw.approved.txt       | 16 ++++++++--------
 tests/SelfTest/UsageTests/Matchers.tests.cpp       | 18 ++++++++++--------
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 05fc49df..bb73ca18 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -435,10 +435,10 @@ Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
 Matchers.tests.cpp:<line number>: passed: matcher.match(1) for: true
 Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
 Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
-Matchers.tests.cpp:<line number>: passed: 1, !(first && second) for: 1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
+Matchers.tests.cpp:<line number>: passed: !(matcher.match( 1 )) for: !false
 Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
 Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
-Matchers.tests.cpp:<line number>: passed: 1, first || second for: 1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
+Matchers.tests.cpp:<line number>: passed: matcher.match( 1 ) for: true
 Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
 Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
 Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive)
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 0f239c76..e4298d25 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -3419,16 +3419,15 @@ with expansion:
 
 -------------------------------------------------------------------------------
 Composed matchers shortcircuit
-  &&
+  MatchAllOf
 -------------------------------------------------------------------------------
 Matchers.tests.cpp:<line number>
 ...............................................................................
 
 Matchers.tests.cpp:<line number>: PASSED:
-  CHECK_THAT( 1, !(first && second) )
+  CHECK_FALSE( matcher.match( 1 ) )
 with expansion:
-  1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to
-  fail )
+  !false
 
 Matchers.tests.cpp:<line number>: PASSED:
   REQUIRE( first.matchCalled )
@@ -3442,16 +3441,15 @@ with expansion:
 
 -------------------------------------------------------------------------------
 Composed matchers shortcircuit
-  ||
+  MatchAnyOf
 -------------------------------------------------------------------------------
 Matchers.tests.cpp:<line number>
 ...............................................................................
 
 Matchers.tests.cpp:<line number>: PASSED:
-  CHECK_THAT( 1, first || second )
+  CHECK( matcher.match( 1 ) )
 with expansion:
-  1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail
-  )
+  true
 
 Matchers.tests.cpp:<line number>: PASSED:
   REQUIRE( first.matchCalled )
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 7ef0bba4..e4004469 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -392,8 +392,8 @@ Exception.tests.cpp:<line number>
     <testcase classname="<exe-name>.global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="Composed generic matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="Composed generic matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/>
-    <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/&amp;&amp;" time="{duration}" status="run"/>
-    <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/||" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run">
       <failure message="testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No)" type="CHECK_THAT">
 FAILED:
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 1fd944a4..44f3adab 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -959,8 +959,8 @@ Exception.tests.cpp:<line number>
     <testCase name="Combining templated matchers" duration="{duration}"/>
     <testCase name="Composed generic matchers shortcircuit/MatchAllOf" duration="{duration}"/>
     <testCase name="Composed generic matchers shortcircuit/MatchAnyOf" duration="{duration}"/>
-    <testCase name="Composed matchers shortcircuit/&amp;&amp;" duration="{duration}"/>
-    <testCase name="Composed matchers shortcircuit/||" duration="{duration}"/>
+    <testCase name="Composed matchers shortcircuit/MatchAllOf" duration="{duration}"/>
+    <testCase name="Composed matchers shortcircuit/MatchAnyOf" duration="{duration}"/>
     <testCase name="Contains string matcher" duration="{duration}">
       <failure message="CHECK_THAT(testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No))">
 FAILED:
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 6fb2aa15..187c6a42 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -869,13 +869,13 @@ ok {test-number} - first.matchCalled for: true
 # Composed generic matchers shortcircuit
 ok {test-number} - !second.matchCalled for: true
 # Composed matchers shortcircuit
-ok {test-number} - 1, !(first && second) for: 1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
+ok {test-number} - !(matcher.match( 1 )) for: !false
 # Composed matchers shortcircuit
 ok {test-number} - first.matchCalled for: true
 # Composed matchers shortcircuit
 ok {test-number} - !second.matchCalled for: true
 # Composed matchers shortcircuit
-ok {test-number} - 1, first || second for: 1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
+ok {test-number} - matcher.match( 1 ) for: true
 # Composed matchers shortcircuit
 ok {test-number} - first.matchCalled for: true
 # Composed matchers shortcircuit
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index c2109e5d..8604c74b 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -3769,13 +3769,13 @@ Nor would this
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="Composed matchers shortcircuit" tags="[composed][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
-      <Section name="&amp;&amp;" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
-        <Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+      <Section name="MatchAllOf" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+        <Expression success="true" type="CHECK_FALSE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            1, !(first &amp;&amp; second)
+            !(matcher.match( 1 ))
           </Original>
           <Expanded>
-            1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
+            !false
           </Expanded>
         </Expression>
         <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
@@ -3796,13 +3796,13 @@ Nor would this
         </Expression>
         <OverallResults successes="3" failures="0" expectedFailures="0"/>
       </Section>
-      <Section name="||" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
-        <Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+      <Section name="MatchAnyOf" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            1, first || second
+            matcher.match( 1 )
           </Original>
           <Expanded>
-            1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
+            true
           </Expanded>
         </Expression>
         <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp
index 8276cf84..b627d4a9 100644
--- a/tests/SelfTest/UsageTests/Matchers.tests.cpp
+++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp
@@ -638,22 +638,24 @@ namespace { namespace MatchersTests {
         TEST_CASE("Composed matchers shortcircuit", "[matchers][composed]") {
             // Check that if first returns false, second is not touched
             CheckedTestingMatcher first, second;
-            SECTION("&&") {
+            SECTION("MatchAllOf") {
                 first.matchSucceeds = false;
-                // This assertion doesn't actually test anything, we just
-                // want the composed matcher's `match` being called.
-                CHECK_THAT(1, !(first && second));
+
+                Detail::MatchAllOf<int> matcher =
+                    Detail::MatchAllOf<int>{} && first && second;
+                CHECK_FALSE( matcher.match( 1 ) );
 
                 // These two assertions are the important ones
                 REQUIRE(first.matchCalled);
                 REQUIRE(!second.matchCalled);
             }
             // Check that if first returns true, second is not touched
-            SECTION("||") {
+            SECTION("MatchAnyOf") {
                 first.matchSucceeds = true;
-                // This assertion doesn't actually test anything, we just
-                // want the composed matcher's `match` being called.
-                CHECK_THAT(1, first || second);
+
+                Detail::MatchAnyOf<int> matcher =
+                    Detail::MatchAnyOf<int>{} || first || second;
+                CHECK( matcher.match( 1 ) );
 
                 // These two assertions are the important ones
                 REQUIRE(first.matchCalled);