mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Fixup template type argument inference for vector matchers
This commit is contained in:
parent
cfb6956698
commit
f4fc2dab2c
@ -151,7 +151,7 @@ namespace Matchers {
|
||||
// The following functions create the actual matcher objects.
|
||||
// This allows the types to be inferred
|
||||
|
||||
template<typename T, typename AllocComp, typename AllocMatch = AllocComp>
|
||||
template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
|
||||
Vector::ContainsMatcher<T, AllocComp, AllocMatch> Contains( std::vector<T, AllocComp> const& comparator ) {
|
||||
return Vector::ContainsMatcher<T, AllocComp, AllocMatch>( comparator );
|
||||
}
|
||||
@ -161,17 +161,17 @@ namespace Matchers {
|
||||
return Vector::ContainsElementMatcher<T, Alloc>( comparator );
|
||||
}
|
||||
|
||||
template<typename T, typename AllocComp, typename AllocMatch = AllocComp>
|
||||
template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
|
||||
Vector::EqualsMatcher<T, AllocComp, AllocMatch> Equals( std::vector<T, AllocComp> const& comparator ) {
|
||||
return Vector::EqualsMatcher<T, AllocComp, AllocMatch>( comparator );
|
||||
}
|
||||
|
||||
template<typename T, typename AllocComp, typename AllocMatch = AllocComp>
|
||||
template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
|
||||
Vector::ApproxMatcher<T, AllocComp, AllocMatch> Approx( std::vector<T, AllocComp> const& comparator ) {
|
||||
return Vector::ApproxMatcher<T, AllocComp, AllocMatch>( comparator );
|
||||
}
|
||||
|
||||
template<typename T, typename AllocComp, typename AllocMatch = AllocComp>
|
||||
template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp>
|
||||
Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch> UnorderedEquals(std::vector<T, AllocComp> const& target) {
|
||||
return Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch>( target );
|
||||
}
|
||||
|
@ -1529,6 +1529,7 @@ Approx.tests.cpp:<line number>: passed: approx( d ) != 1.25 for: Approx( 1.23 )
|
||||
VariadicMacros.tests.cpp:<line number>: passed: with 1 message: 'no assertions'
|
||||
Matchers.tests.cpp:<line number>: passed: empty, Approx(empty) for: { } is approx: { }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, Approx(v1) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, Approx<double>({ 1., 2., 3. }) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, !Approx(temp) for: { 1.0, 2.0, 3.0 } not is approx: { 1.0, 2.0, 3.0, 4.0 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, !Approx(v2) for: { 1.0, 2.0, 3.0 } not is approx: { 1.5, 2.5, 3.5 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, Approx(v2).margin(0.5) for: { 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
@ -1540,6 +1541,7 @@ Matchers.tests.cpp:<line number>: passed: v, VectorContains(1) for: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, VectorContains(2) for: { 1, 2, 3 } Contains: 2
|
||||
Matchers.tests.cpp:<line number>: passed: v5, (VectorContains<int, CustomAllocator<int>>(2)) for: { 1, 2, 3 } Contains: 2
|
||||
Matchers.tests.cpp:<line number>: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, Contains<int>({ 1, 2 }) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, Contains(empty) for: { 1, 2, 3 } Contains: { }
|
||||
@ -1549,10 +1551,12 @@ Matchers.tests.cpp:<line number>: passed: v5, Contains(v6) for: { 1, 2, 3 } Cont
|
||||
Matchers.tests.cpp:<line number>: passed: v, VectorContains(1) && VectorContains(2) for: { 1, 2, 3 } ( Contains: 1 and Contains: 2 )
|
||||
Matchers.tests.cpp:<line number>: passed: v, Equals(v) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: empty, Equals(empty) for: { } Equals: { }
|
||||
Matchers.tests.cpp:<line number>: passed: v, Equals<int>({ 1, 2, 3 }) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, Equals(v2) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, Equals(v6) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, UnorderedEquals(v) for: { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, UnorderedEquals<int>({ 3, 2, 1 }) for: { 1, 2, 3 } UnorderedEquals: { 3, 2, 1 }
|
||||
Matchers.tests.cpp:<line number>: passed: empty, UnorderedEquals(empty) for: { } UnorderedEquals: { }
|
||||
Matchers.tests.cpp:<line number>: passed: permuted, UnorderedEquals(v) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: permuted, UnorderedEquals(v) for: { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 }
|
||||
|
@ -1381,5 +1381,5 @@ due to unexpected exception with message:
|
||||
|
||||
===============================================================================
|
||||
test cases: 310 | 236 passed | 70 failed | 4 failed as expected
|
||||
assertions: 1695 | 1543 passed | 131 failed | 21 failed as expected
|
||||
assertions: 1699 | 1547 passed | 131 failed | 21 failed as expected
|
||||
|
||||
|
@ -11177,6 +11177,11 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, Approx<double>({ 1., 2., 3. }) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher
|
||||
Vectors with elements
|
||||
@ -11276,6 +11281,11 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v, Contains<int>({ 1, 2 }) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) )
|
||||
with expansion:
|
||||
@ -11335,6 +11345,11 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ } Equals: { }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v, Equals<int>({ 1, 2, 3 }) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v, Equals(v2) )
|
||||
with expansion:
|
||||
@ -11362,6 +11377,11 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ 1, 2, 3 } UnorderedEquals: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v, UnorderedEquals<int>({ 3, 2, 1 }) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } UnorderedEquals: { 3, 2, 1 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( empty, UnorderedEquals(empty) )
|
||||
with expansion:
|
||||
@ -13544,5 +13564,5 @@ Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 310 | 220 passed | 86 failed | 4 failed as expected
|
||||
assertions: 1712 | 1543 passed | 148 failed | 21 failed as expected
|
||||
assertions: 1716 | 1547 passed | 148 failed | 21 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="1713" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="1717" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
|
@ -13624,9 +13624,17 @@ There is no extra whitespace here
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx<double>({ 1., 2., 3. })
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Vectors with elements" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Different length" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -13744,6 +13752,14 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, Contains<int>({ 1, 2 })
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2))
|
||||
@ -13792,7 +13808,7 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="7" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="8" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Contains (element), composed" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -13822,6 +13838,14 @@ There is no extra whitespace here
|
||||
{ } Equals: { }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, Equals<int>({ 1, 2, 3 })
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, Equals(v2)
|
||||
@ -13846,7 +13870,7 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="5" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="UnorderedEquals" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -13857,6 +13881,14 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } UnorderedEquals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, UnorderedEquals<int>({ 3, 2, 1 })
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } UnorderedEquals: { 3, 2, 1 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
empty, UnorderedEquals(empty)
|
||||
@ -13897,7 +13929,7 @@ There is no extra whitespace here
|
||||
{ 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="7" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
@ -16207,7 +16239,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1543" failures="149" expectedFailures="21"/>
|
||||
<OverallResults successes="1547" failures="149" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="1543" failures="148" expectedFailures="21"/>
|
||||
<OverallResults successes="1547" failures="148" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@ -288,6 +288,7 @@ namespace { namespace MatchersTests {
|
||||
}
|
||||
SECTION("Contains (vector)") {
|
||||
CHECK_THAT(v, Contains(v2));
|
||||
CHECK_THAT(v, Contains<int>({ 1, 2 }));
|
||||
CHECK_THAT(v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)));
|
||||
|
||||
v2.push_back(3); // now exactly matches
|
||||
@ -307,10 +308,10 @@ namespace { namespace MatchersTests {
|
||||
|
||||
// Same vector
|
||||
CHECK_THAT(v, Equals(v));
|
||||
|
||||
CHECK_THAT(empty, Equals(empty));
|
||||
|
||||
// Different vector with same elements
|
||||
CHECK_THAT(v, Equals<int>({ 1, 2, 3 }));
|
||||
v2.push_back(3);
|
||||
CHECK_THAT(v, Equals(v2));
|
||||
|
||||
@ -321,6 +322,7 @@ namespace { namespace MatchersTests {
|
||||
}
|
||||
SECTION("UnorderedEquals") {
|
||||
CHECK_THAT(v, UnorderedEquals(v));
|
||||
CHECK_THAT(v, UnorderedEquals<int>({ 3, 2, 1 }));
|
||||
CHECK_THAT(empty, UnorderedEquals(empty));
|
||||
|
||||
auto permuted = v;
|
||||
@ -580,6 +582,7 @@ namespace { namespace MatchersTests {
|
||||
std::vector<double> v1({1., 2., 3.});
|
||||
SECTION("A vector is approx equal to itself") {
|
||||
REQUIRE_THAT(v1, Approx(v1));
|
||||
REQUIRE_THAT(v1, Approx<double>({ 1., 2., 3. }));
|
||||
}
|
||||
std::vector<double> v2({1.5, 2.5, 3.5});
|
||||
SECTION("Different length") {
|
||||
@ -614,7 +617,7 @@ namespace { namespace MatchersTests {
|
||||
REQUIRE_THROWS_MATCHES(throwsSpecialException(2), SpecialException, !Message("DerivedException::what"));
|
||||
REQUIRE_THROWS_MATCHES(throwsSpecialException(2), SpecialException, Message("SpecialException::what"));
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Composed matchers are distinct", "[matchers][composed]") {
|
||||
auto m1 = Contains("string");
|
||||
auto m2 = Contains("random");
|
||||
|
Loading…
Reference in New Issue
Block a user