Removed vestigal ComparatorT template arg to MatcherBase

This commit is contained in:
Phil Nash 2017-11-13 10:06:26 +00:00
parent b74d4ca96d
commit 3537b7858f
7 changed files with 50 additions and 22 deletions

View File

@ -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

View File

@ -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 ) {}

View File

@ -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

View File

@ -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

View File

@ -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">

View File

@ -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 ) &amp;&amp; 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>

View File

@ -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" ) {