From d0eb9dfb9b95b97d31656acd13bb9cfb445bc734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 4 Nov 2018 00:00:36 +0100 Subject: [PATCH] Remove unused partial specialization for MatcherMethod 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. --- include/internal/catch_matchers.h | 4 ---- .../SelfTest/Baselines/compact.sw.approved.txt | 1 + .../SelfTest/Baselines/console.std.approved.txt | 4 ++-- .../SelfTest/Baselines/console.sw.approved.txt | 16 ++++++++++++++-- .../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 - struct MatcherMethod { - 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:: passed: cpc != 0 for: 0x != 0 Condition.tests.cpp:: passed: returnsNull() == 0 for: {null string} == 0 Condition.tests.cpp:: passed: returnsConstNull() == 0 for: {null string} == 0 Condition.tests.cpp:: passed: 0 != p for: 0 != 0x +Matchers.tests.cpp:: passed: "foo", Predicate([] (const char* const&) { return true; }) for: "foo" matches undescribed predicate CmdLine.tests.cpp:: passed: result for: {?} CmdLine.tests.cpp:: passed: config.processName == "" for: "" == "" CmdLine.tests.cpp:: 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 +------------------------------------------------------------------------------- +Predicate matcher can accept const char* +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( "foo", Predicate([] (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:: 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 @@ - + @@ -480,6 +480,7 @@ Message.tests.cpp: + 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 @@ + + + + "foo", Predicate<const char*>([] (const char* const&) { return true; }) + + + "foo" matches undescribed predicate + + + +
@@ -11358,7 +11369,7 @@ loose text artifact
- + - + 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&) { return true; })); + } + } } // namespace MatchersTests #endif // CATCH_CONFIG_DISABLE_MATCHERS