mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Support custom allocators in vector Matchers (#1909)
-- Combined with f4fc2dab2c
during cherry-picking.
This commit is contained in:

committed by
Martin Hořeňovský

parent
dd35430a2b
commit
2a93a65bc2
@@ -1603,6 +1603,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 }
|
||||
@@ -1612,18 +1613,29 @@ Matchers.tests.cpp:<line number>: failed: empty, Approx(t1) for: { } is approx:
|
||||
Matchers.tests.cpp:<line number>: failed: v1, Approx(v2) for: { 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 }
|
||||
Matchers.tests.cpp:<line number>: passed: v, VectorContains(1) for: { 1, 2, 3 } Contains: 1
|
||||
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: { }
|
||||
Matchers.tests.cpp:<line number>: passed: empty, Contains(empty) for: { } Contains: { }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, Contains(v6) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
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 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted)) for: { 1, 2, 3 } UnorderedEquals: { 2, 3, 1 }
|
||||
Matchers.tests.cpp:<line number>: passed: v5_permuted, UnorderedEquals(v5) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
Matchers.tests.cpp:<line number>: failed: v, VectorContains(-1) for: { 1, 2, 3 } Contains: -1
|
||||
Matchers.tests.cpp:<line number>: failed: empty, VectorContains(1) for: { } Contains: 1
|
||||
Matchers.tests.cpp:<line number>: failed: empty, Contains(v) for: { } Contains: { 1, 2, 3 }
|
||||
|
@@ -1381,5 +1381,5 @@ due to unexpected exception with message:
|
||||
|
||||
===============================================================================
|
||||
test cases: 334 | 260 passed | 70 failed | 4 failed as expected
|
||||
assertions: 1880 | 1728 passed | 131 failed | 21 failed as expected
|
||||
assertions: 1892 | 1740 passed | 131 failed | 21 failed as expected
|
||||
|
||||
|
@@ -11676,6 +11676,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
|
||||
@@ -11758,6 +11763,11 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: 2
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, (VectorContains<int, CustomAllocator<int>>(2)) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers
|
||||
Contains (vector)
|
||||
@@ -11770,6 +11780,16 @@ 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:
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v, Contains(v2) )
|
||||
with expansion:
|
||||
@@ -11785,6 +11805,16 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ } Contains: { }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, Contains(v6) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers
|
||||
Contains (element), composed
|
||||
@@ -11814,11 +11844,26 @@ 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:
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2)) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, Equals(v6) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers
|
||||
UnorderedEquals
|
||||
@@ -11831,6 +11876,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:
|
||||
@@ -11846,6 +11896,16 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
{ 2, 3, 1 } UnorderedEquals: { 1, 2, 3 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted)) )
|
||||
with expansion:
|
||||
{ 1, 2, 3 } UnorderedEquals: { 2, 3, 1 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( v5_permuted, UnorderedEquals(v5) )
|
||||
with expansion:
|
||||
{ 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers that fail
|
||||
Contains (element)
|
||||
@@ -14714,5 +14774,5 @@ Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 334 | 244 passed | 86 failed | 4 failed as expected
|
||||
assertions: 1897 | 1728 passed | 148 failed | 21 failed as expected
|
||||
assertions: 1909 | 1740 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="1898" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="1910" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
|
@@ -3054,6 +3054,8 @@ ok {test-number} - empty, Approx(empty) for: { } is approx: { }
|
||||
# Vector Approx matcher
|
||||
ok {test-number} - v1, Approx(v1) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
# Vector Approx matcher
|
||||
ok {test-number} - v1, Approx<double>({ 1., 2., 3. }) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
# Vector Approx matcher
|
||||
ok {test-number} - v1, !Approx(temp) for: { 1.0, 2.0, 3.0 } not is approx: { 1.0, 2.0, 3.0, 4.0 }
|
||||
# Vector Approx matcher
|
||||
ok {test-number} - v1, !Approx(v2) for: { 1.0, 2.0, 3.0 } not is approx: { 1.5, 2.5, 3.5 }
|
||||
@@ -3072,29 +3074,51 @@ ok {test-number} - v, VectorContains(1) for: { 1, 2, 3 } Contains: 1
|
||||
# Vector matchers
|
||||
ok {test-number} - v, VectorContains(2) for: { 1, 2, 3 } Contains: 2
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, (VectorContains<int, CustomAllocator<int>>(2)) for: { 1, 2, 3 } Contains: 2
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Contains<int>({ 1, 2 }) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Contains(empty) for: { 1, 2, 3 } Contains: { }
|
||||
# Vector matchers
|
||||
ok {test-number} - empty, Contains(empty) for: { } Contains: { }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, Contains(v6) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, VectorContains(1) && VectorContains(2) for: { 1, 2, 3 } ( Contains: 1 and Contains: 2 )
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Equals(v) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - empty, Equals(empty) for: { } Equals: { }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Equals<int>({ 1, 2, 3 }) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, Equals(v2) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2)) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, Equals(v6) for: { 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, UnorderedEquals(v) for: { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v, UnorderedEquals<int>({ 3, 2, 1 }) for: { 1, 2, 3 } UnorderedEquals: { 3, 2, 1 }
|
||||
# Vector matchers
|
||||
ok {test-number} - empty, UnorderedEquals(empty) for: { } UnorderedEquals: { }
|
||||
# Vector matchers
|
||||
ok {test-number} - permuted, UnorderedEquals(v) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - permuted, UnorderedEquals(v) for: { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted)) for: { 1, 2, 3 } UnorderedEquals: { 2, 3, 1 }
|
||||
# Vector matchers
|
||||
ok {test-number} - v5_permuted, UnorderedEquals(v5) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
# Vector matchers that fail
|
||||
not ok {test-number} - v, VectorContains(-1) for: { 1, 2, 3 } Contains: -1
|
||||
# Vector matchers that fail
|
||||
@@ -3786,5 +3810,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
||||
ok {test-number} -
|
||||
# xmlentitycheck
|
||||
ok {test-number} -
|
||||
1..1889
|
||||
1..1901
|
||||
|
||||
|
@@ -14099,9 +14099,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="tests/<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="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Different length" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@@ -14200,7 +14208,15 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Contains: 2
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (VectorContains<int, CustomAllocator<int>>(2))
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Contains: 2
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Contains (vector)" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@@ -14211,6 +14227,22 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<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="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2))
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, Contains(v2)
|
||||
@@ -14235,7 +14267,23 @@ There is no extra whitespace here
|
||||
{ } Contains: { }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2))
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Contains: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, Contains(v6)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Contains: { 1, 2 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="8" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Contains (element), composed" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@@ -14265,6 +14313,14 @@ There is no extra whitespace here
|
||||
{ } Equals: { }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<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="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v, Equals(v2)
|
||||
@@ -14273,7 +14329,23 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2))
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, Equals(v6)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } Equals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="UnorderedEquals" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@@ -14284,6 +14356,14 @@ There is no extra whitespace here
|
||||
{ 1, 2, 3 } UnorderedEquals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<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="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
empty, UnorderedEquals(empty)
|
||||
@@ -14308,7 +14388,23 @@ There is no extra whitespace here
|
||||
{ 2, 3, 1 } UnorderedEquals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted))
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 2, 3 } UnorderedEquals: { 2, 3, 1 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v5_permuted, UnorderedEquals(v5)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1, 3, 2 } UnorderedEquals: { 1, 2, 3 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="7" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
@@ -17636,7 +17732,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1728" failures="149" expectedFailures="21"/>
|
||||
<OverallResults successes="1740" failures="149" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="1728" failures="148" expectedFailures="21"/>
|
||||
<OverallResults successes="1740" failures="148" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@@ -217,6 +217,42 @@ namespace { namespace MatchersTests {
|
||||
CHECK_THAT(testStringForMatching(), !Contains("substring"));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct CustomAllocator : private std::allocator<T>
|
||||
{
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using value_type = T;
|
||||
|
||||
template<typename U>
|
||||
struct rebind
|
||||
{ using other = CustomAllocator<U>; };
|
||||
|
||||
using propagate_on_container_move_assignment = std::true_type;
|
||||
using is_always_equal = std::true_type;
|
||||
|
||||
CustomAllocator() = default;
|
||||
|
||||
CustomAllocator(const CustomAllocator& other)
|
||||
: std::allocator<T>(other) { }
|
||||
|
||||
template<typename U>
|
||||
CustomAllocator(const CustomAllocator<U>&) { }
|
||||
|
||||
~CustomAllocator() = default;
|
||||
|
||||
using std::allocator<T>::address;
|
||||
using std::allocator<T>::allocate;
|
||||
using std::allocator<T>::construct;
|
||||
using std::allocator<T>::deallocate;
|
||||
using std::allocator<T>::max_size;
|
||||
using std::allocator<T>::destroy;
|
||||
};
|
||||
|
||||
TEST_CASE("Vector matchers", "[matchers][vector]") {
|
||||
std::vector<int> v;
|
||||
v.push_back(1);
|
||||
@@ -237,19 +273,35 @@ namespace { namespace MatchersTests {
|
||||
v4.push_back(2 + 1e-8);
|
||||
v4.push_back(3 + 1e-8);
|
||||
|
||||
std::vector<int, CustomAllocator<int>> v5;
|
||||
v5.push_back(1);
|
||||
v5.push_back(2);
|
||||
v5.push_back(3);
|
||||
|
||||
std::vector<int, CustomAllocator<int>> v6;
|
||||
v6.push_back(1);
|
||||
v6.push_back(2);
|
||||
|
||||
std::vector<int> empty;
|
||||
|
||||
SECTION("Contains (element)") {
|
||||
CHECK_THAT(v, VectorContains(1));
|
||||
CHECK_THAT(v, VectorContains(2));
|
||||
CHECK_THAT(v5, (VectorContains<int, CustomAllocator<int>>(2)));
|
||||
}
|
||||
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
|
||||
CHECK_THAT(v, Contains(v2));
|
||||
|
||||
CHECK_THAT(v, Contains(empty));
|
||||
CHECK_THAT(empty, Contains(empty));
|
||||
|
||||
CHECK_THAT(v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)));
|
||||
CHECK_THAT(v5, Contains(v6));
|
||||
}
|
||||
SECTION("Contains (element), composed") {
|
||||
CHECK_THAT(v, VectorContains(1) && VectorContains(2));
|
||||
@@ -263,11 +315,18 @@ namespace { namespace MatchersTests {
|
||||
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));
|
||||
|
||||
CHECK_THAT(v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2)));
|
||||
|
||||
v6.push_back(3);
|
||||
CHECK_THAT(v5, Equals(v6));
|
||||
}
|
||||
SECTION("UnorderedEquals") {
|
||||
CHECK_THAT(v, UnorderedEquals(v));
|
||||
CHECK_THAT(v, UnorderedEquals<int>({ 3, 2, 1 }));
|
||||
CHECK_THAT(empty, UnorderedEquals(empty));
|
||||
|
||||
auto permuted = v;
|
||||
@@ -276,6 +335,12 @@ namespace { namespace MatchersTests {
|
||||
|
||||
std::reverse(begin(permuted), end(permuted));
|
||||
REQUIRE_THAT(permuted, UnorderedEquals(v));
|
||||
|
||||
CHECK_THAT(v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted)));
|
||||
|
||||
auto v5_permuted = v5;
|
||||
std::next_permutation(begin(v5_permuted), end(v5_permuted));
|
||||
CHECK_THAT(v5_permuted, UnorderedEquals(v5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,6 +586,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") {
|
||||
|
Reference in New Issue
Block a user