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

Remove unused partial specialization for MatcherMethod<T>

No matcher actually uses it, and there is no good reason for it,
as the best it can do for user is removing a single indirection
when using the pointer inside the matcher. Given the overhead of
other code that will be running during such time, it is completely
meaningless.

This also fixes compilation for PredicateMatcher<const char*>.
Commit
d0eb9dfb9b95b97d31656acd13bb9cfb445bc734
Author
Martin Hořeňovský ·
Parents
03d122a35c3f

Files · Download .tar.gz

Changes

 include/internal/catch_matchers.h                    |  4 ----
 projects/SelfTest/Baselines/compact.sw.approved.txt  |  1 +
 projects/SelfTest/Baselines/console.std.approved.txt |  4 ++--
 projects/SelfTest/Baselines/console.sw.approved.txt  | 16 ++++++++++++++--
 projects/SelfTest/Baselines/junit.sw.approved.txt    |  3 ++-
 projects/SelfTest/Baselines/xml.sw.approved.txt      | 15 +++++++++++++--
 projects/SelfTest/UsageTests/Matchers.tests.cpp      |  4 ++++
 7 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/include/internal/catch_matchers.h b/include/internal/catch_matchers.h
index 29692fc0..aebd4c23 100644
--- a/include/internal/catch_matchers.h
+++ b/include/internal/catch_matchers.h
@@ -43,10 +43,6 @@ namespace Matchers {
         struct MatcherMethod {
             virtual bool match( ObjectT const& arg ) const = 0;
         };
-        template<typename PtrT>
-        struct MatcherMethod<PtrT*> {
-            virtual bool match( PtrT* arg ) const = 0;
-        };
 
 #ifdef __clang__
 #    pragma clang diagnostic pop
diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt
index 2b1b917a..41b63712 100644
--- a/projects/SelfTest/Baselines/compact.sw.approved.txt
+++ b/projects/SelfTest/Baselines/compact.sw.approved.txt
@@ -679,6 +679,7 @@ Condition.tests.cpp:<line number>: passed: cpc != 0 for: 0x<hex digits> != 0
 Condition.tests.cpp:<line number>: passed: returnsNull() == 0 for: {null string} == 0
 Condition.tests.cpp:<line number>: passed: returnsConstNull() == 0 for: {null string} == 0
 Condition.tests.cpp:<line number>: passed: 0 != p for: 0 != 0x<hex digits>
+Matchers.tests.cpp:<line number>: passed: "foo", Predicate<const char*>([] (const char* const&) { return true; }) for: "foo" matches undescribed predicate
 CmdLine.tests.cpp:<line number>: passed: result for: {?}
 CmdLine.tests.cpp:<line number>: passed: config.processName == "" for: "" == ""
 CmdLine.tests.cpp:<line number>: passed: result for: {?}
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index 7d3a4db4..9bcfda97 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -1098,6 +1098,6 @@ due to unexpected exception with message:
   Why would you throw a std::string?
 
 ===============================================================================
-test cases:  215 |  162 passed |  49 failed |  4 failed as expected
-assertions: 1233 | 1104 passed | 108 failed | 21 failed as expected
+test cases:  216 |  163 passed |  49 failed |  4 failed as expected
+assertions: 1234 | 1105 passed | 108 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index da0950de..b58f8356 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -5739,6 +5739,18 @@ PASSED:
 with expansion:
   0 != 0x<hex digits>
 
+-------------------------------------------------------------------------------
+Predicate matcher can accept const char*
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>:
+PASSED:
+  REQUIRE_THAT( "foo", Predicate<const char*>([] (const char* const&) { return true; }) )
+with expansion:
+  "foo" matches undescribed predicate
+
 -------------------------------------------------------------------------------
 Process can be configured on command line
   empty args don't cause a crash
@@ -10885,6 +10897,6 @@ Misc.tests.cpp:<line number>:
 PASSED:
 
 ===============================================================================
-test cases:  215 |  149 passed |  62 failed |  4 failed as expected
-assertions: 1247 | 1104 passed | 122 failed | 21 failed as expected
+test cases:  216 |  150 passed |  62 failed |  4 failed as expected
+assertions: 1248 | 1105 passed | 122 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 0b726c8d..b62c62aa 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuitesloose text artifact
 >
-  <testsuite name="<exe-name>" errors="17" failures="106" tests="1248" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="17" failures="106" tests="1249" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
@@ -480,6 +480,7 @@ Message.tests.cpp:<line number>
     <testcase classname="<exe-name>.global" name="Parse test names and tags/empty quoted name" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="Parse test names and tags/quoted string followed by tag exclusion" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="Pointers can be compared to null" time="{duration}"/>
+    <testcase classname="<exe-name>.global" name="Predicate matcher can accept const char*" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="Process can be configured on command line/empty args don't cause a crash" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="Process can be configured on command line/default - no arguments" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="Process can be configured on command line/test lists/Specify one test case using" time="{duration}"/>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index f573f585..00ea5f76 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -5964,6 +5964,17 @@
       </Expression>
       <OverallResult success="true"/>
     </TestCase>
+    <TestCase name="Predicate matcher can accept const char*" tags="[compilation][matchers]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
+      <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
+        <Original>
+          "foo", Predicate&lt;const char*>([] (const char* const&amp;) { return true; })
+        </Original>
+        <Expanded>
+          "foo" matches undescribed predicate
+        </Expanded>
+      </Expression>
+      <OverallResult success="true"/>
+    </TestCase>
     <TestCase name="Process can be configured on command line" tags="[command-line][config]" filename="projects/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
       <Section name="empty args don't cause a crash" filename="projects/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
         <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
@@ -11358,7 +11369,7 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="1104" failures="123" expectedFailures="21"/>
+    <OverallResults successes="1105" failures="123" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="1104" failures="122" expectedFailures="21"/>
+  <OverallResults successes="1105" failures="122" expectedFailures="21"/>
 </Catch>
diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp
index e09dad14..f07481d4 100644
--- a/projects/SelfTest/UsageTests/Matchers.tests.cpp
+++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp
@@ -432,6 +432,10 @@ namespace { namespace MatchersTests {
             CHECK_THAT(actual, !UnorderedEquals(expected));
         }
 
+        TEST_CASE("Predicate matcher can accept const char*", "[matchers][compilation]") {
+            REQUIRE_THAT("foo", Predicate<const char*>([] (const char* const&) { return true; }));
+        }
+
 } } // namespace MatchersTests
 
 #endif // CATCH_CONFIG_DISABLE_MATCHERS