Feature: generic matchers (#1843)

This commit extends the Matchers feature with the ability to have type-independent (e.g. templated) matchers. This is done by adding a new base type that Matchers can extend, `MatcherGenericBase`, and overloads of operators `!`, `&&` and `||` that handle matchers extending `MatcherGenericBase` in a special manner.

These new matchers can also take their arguments as values and non-const references.

Closes #1307 
Closes #1553 
Closes #1554 

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
This commit is contained in:
melak47
2020-02-16 11:19:10 +01:00
committed by GitHub
parent db1a0465dc
commit 17c4b2d093
15 changed files with 1192 additions and 16 deletions

View File

@@ -915,6 +915,13 @@ Exception.tests.cpp:<line number>
<file path="tests/<exe-name>/UsageTests/Matchers.tests.cpp">
<testCase name="Arbitrary predicate matcher/Function pointer" duration="{duration}"/>
<testCase name="Arbitrary predicate matcher/Lambdas + different type" duration="{duration}"/>
<testCase name="Combining MatchAllOfGeneric does not nest" duration="{duration}"/>
<testCase name="Combining MatchAnyOfGeneric does not nest" duration="{duration}"/>
<testCase name="Combining MatchNotOfGeneric does not nest" duration="{duration}"/>
<testCase name="Combining concrete matchers does not use templated matchers" duration="{duration}"/>
<testCase name="Combining only templated matchers" duration="{duration}"/>
<testCase name="Combining templated and concrete matchers" duration="{duration}"/>
<testCase name="Combining templated matchers" duration="{duration}"/>
<testCase name="Contains string matcher" duration="{duration}">
<failure message="CHECK_THAT(testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No))">
FAILED:
@@ -1042,6 +1049,7 @@ with expansion:
Matchers.tests.cpp:<line number>
</failure>
</testCase>
<testCase name="Overloaded comma or address-of operators are not used" duration="{duration}"/>
<testCase name="Predicate matcher can accept const char*" duration="{duration}"/>
<testCase name="Regex string matcher" duration="{duration}">
<failure message="CHECK_THAT(testStringForMatching(), Matches(&quot;this STRING contains 'abc' as a substring&quot;))">