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
Removed vestigal ComparatorT template arg to MatcherBase
- Commit
3537b7858f54730f501e24d17582603c0d0d7d0b- Author
- Phil Nash ·
- Parents
b74d4ca96dac
Changes
include/internal/catch_matchers.h | 28 +++++++++++----------- include/internal/catch_matchers_vector.h | 6 ++--- .../SelfTest/Baselines/console.std.approved.txt | 2 +- .../SelfTest/Baselines/console.sw.approved.txt | 15 +++++++++++- projects/SelfTest/Baselines/junit.sw.approved.txt | 3 ++- projects/SelfTest/Baselines/xml.sw.approved.txt | 15 ++++++++++-- projects/SelfTest/MatchersTests.cpp | 3 +++ 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/include/internal/catch_matchers.h b/include/internal/catch_matchers.h index 8c15d425..f2e3aee9 100644 --- a/include/internal/catch_matchers.h +++ b/include/internal/catch_matchers.h @@ -43,13 +43,13 @@ namespace Matchers { virtual bool match( PtrT* arg ) const = 0; }; - template<typename ObjectT, typename ComparatorT = ObjectT> - struct MatcherBase : MatcherUntypedBase, MatcherMethod<ObjectT> { + template<typename T> + struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> { - MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const; - MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const; - MatchNotOf<ComparatorT> operator ! () const; + MatchAllOf<T> operator && ( MatcherBase const& other ) const; + MatchAnyOf<T> operator || ( MatcherBase const& other ) const; + MatchNotOf<T> operator ! () const; }; template<typename ArgT> @@ -133,17 +133,17 @@ namespace Matchers { MatcherBase<ArgT> const& m_underlyingMatcher; }; - template<typename ObjectT, typename ComparatorT> - MatchAllOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator && ( MatcherBase const& other ) const { - return MatchAllOf<ComparatorT>() && *this && other; + template<typename T> + MatchAllOf<T> MatcherBase<T>::operator && ( MatcherBase const& other ) const { + return MatchAllOf<T>() && *this && other; } - template<typename ObjectT, typename ComparatorT> - MatchAnyOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator || ( MatcherBase const& other ) const { - return MatchAnyOf<ComparatorT>() || *this || other; + template<typename T> + MatchAnyOf<T> MatcherBase<T>::operator || ( MatcherBase const& other ) const { + return MatchAnyOf<T>() || *this || other; } - template<typename ObjectT, typename ComparatorT> - MatchNotOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator ! () const { - return MatchNotOf<ComparatorT>( *this ); + template<typename T> + MatchNotOf<T> MatcherBase<T>::operator ! () const { + return MatchNotOf<T>( *this ); } } // namespace Impl diff --git a/include/internal/catch_matchers_vector.h b/include/internal/catch_matchers_vector.h index ae2741b1..84ffab87 100644 --- a/include/internal/catch_matchers_vector.h +++ b/include/internal/catch_matchers_vector.h @@ -16,7 +16,7 @@ namespace Matchers { namespace Vector { template<typename T> - struct ContainsElementMatcher : MatcherBase<std::vector<T>, T> { + struct ContainsElementMatcher : MatcherBase<std::vector<T>> { ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} @@ -37,7 +37,7 @@ namespace Matchers { }; template<typename T> - struct ContainsMatcher : MatcherBase<std::vector<T>, std::vector<T> > { + struct ContainsMatcher : MatcherBase<std::vector<T>> { ContainsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {} @@ -67,7 +67,7 @@ namespace Matchers { }; template<typename T> - struct EqualsMatcher : MatcherBase<std::vector<T>, std::vector<T> > { + struct EqualsMatcher : MatcherBase<std::vector<T>> { EqualsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {} diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 823e7668..38d1f12a 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1004,5 +1004,5 @@ with expansion: =============================================================================== test cases: 188 | 137 passed | 47 failed | 4 failed as expected -assertions: 939 | 822 passed | 96 failed | 21 failed as expected +assertions: 940 | 823 passed | 96 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 3b3e06e9..9b4d9abc 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -6317,6 +6317,19 @@ PASSED: with expansion: { } Contains: { } +------------------------------------------------------------------------------- +Vector matchers + Contains (element), composed +------------------------------------------------------------------------------- +MatchersTests.cpp:<line number> +............................................................................... + +MatchersTests.cpp:<line number>: +PASSED: + CHECK_THAT( v, VectorContains( 1 ) && VectorContains( 2 ) ) +with expansion: + { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) + ------------------------------------------------------------------------------- Vector matchers Equals @@ -7891,5 +7904,5 @@ PASSED: =============================================================================== test cases: 188 | 135 passed | 49 failed | 4 failed as expected -assertions: 938 | 818 passed | 99 failed | 21 failed as expected +assertions: 939 | 819 passed | 99 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 5744b3bd..fff51dd5 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="15" failures="85" tests="939" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="15" failures="85" tests="940" 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}"/> @@ -580,6 +580,7 @@ ExceptionTests.cpp:<line number> <testcase classname="<exe-name>.global" name="Variadic macros/Section with one argument" time="{duration}"/> <testcase classname="<exe-name>.global" name="Vector matchers/Contains (element)" time="{duration}"/> <testcase classname="<exe-name>.global" name="Vector matchers/Contains (vector)" time="{duration}"/> + <testcase classname="<exe-name>.global" name="Vector matchers/Contains (element), composed" time="{duration}"/> <testcase classname="<exe-name>.global" name="Vector matchers/Equals" time="{duration}"/> <testcase classname="<exe-name>.global" name="Vector matchers that fail/Contains (element)" time="{duration}"> <failure message="{ 1, 2, 3 } Contains: -1" type="CHECK_THAT"> diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index a00e937d..67d6eff0 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -7161,6 +7161,17 @@ Message from section two </Expression> <OverallResults successes="4" failures="0" expectedFailures="0"/> </Section> + <Section name="Contains (element), composed" filename="projects/<exe-name>/MatchersTests.cpp" > + <Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > + <Original> + v, VectorContains( 1 ) && VectorContains( 2 ) + </Original> + <Expanded> + { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> <Section name="Equals" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Original> @@ -8753,7 +8764,7 @@ loose text artifact </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="818" failures="100" expectedFailures="21"/> + <OverallResults successes="819" failures="100" expectedFailures="21"/> </Group> - <OverallResults successes="818" failures="99" expectedFailures="21"/> + <OverallResults successes="819" failures="99" expectedFailures="21"/> </Catch> diff --git a/projects/SelfTest/MatchersTests.cpp b/projects/SelfTest/MatchersTests.cpp index ce4ea0cd..f1da1b36 100644 --- a/projects/SelfTest/MatchersTests.cpp +++ b/projects/SelfTest/MatchersTests.cpp @@ -122,6 +122,9 @@ TEST_CASE( "Vector matchers", "[matchers][vector]" ) { CHECK_THAT( v, Contains( empty) ); CHECK_THAT( empty, Contains( empty) ); } + SECTION( "Contains (element), composed" ) { + CHECK_THAT( v, VectorContains( 1 ) && VectorContains( 2 ) ); + } SECTION( "Equals" ) {