mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Added a vector approximate matcher
This commit is contained in:

committed by
Martin Hořeňovský

parent
45e552528d
commit
91b617c462
@@ -1189,6 +1189,15 @@ Approx.tests.cpp:<line number>: passed: approx( d ) == 1.22 for: Approx( 1.23 )
|
||||
Approx.tests.cpp:<line number>: passed: approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24
|
||||
Approx.tests.cpp:<line number>: passed: approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25
|
||||
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(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 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, Approx(v2).epsilon(0.5) for: { 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
Matchers.tests.cpp:<line number>: passed: v1, Approx(v2).epsilon(0.1).scale(500) for: { 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
Matchers.tests.cpp:<line number>: failed: empty, Approx(t1) for: { } is approx: { 1.0, 2.0 }
|
||||
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: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2 }
|
||||
@@ -1505,5 +1514,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
|
||||
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
|
||||
Misc.tests.cpp:<line number>: passed:
|
||||
Misc.tests.cpp:<line number>: passed:
|
||||
Failed 78 test cases, failed 139 assertions.
|
||||
Failed 79 test cases, failed 141 assertions.
|
||||
|
||||
|
@@ -861,6 +861,30 @@ Exception.tests.cpp:<line number>: FAILED:
|
||||
due to unexpected exception with message:
|
||||
3.14
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher -- failing
|
||||
Empty and non empty vectors are not approx equal
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( empty, Approx(t1) )
|
||||
with expansion:
|
||||
{ } is approx: { 1.0, 2.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher -- failing
|
||||
Just different vectors
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( v1, Approx(v2) )
|
||||
with expansion:
|
||||
{ 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers that fail
|
||||
Contains (element)
|
||||
@@ -1275,6 +1299,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 258 | 192 passed | 62 failed | 4 failed as expected
|
||||
assertions: 1419 | 1276 passed | 122 failed | 21 failed as expected
|
||||
test cases: 260 | 193 passed | 63 failed | 4 failed as expected
|
||||
assertions: 1428 | 1283 passed | 124 failed | 21 failed as expected
|
||||
|
||||
|
@@ -8720,6 +8720,96 @@ VariadicMacros.tests.cpp:<line number>: PASSED:
|
||||
with message:
|
||||
no assertions
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher
|
||||
Empty vector is roughly equal to an empty vector
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( empty, Approx(empty) )
|
||||
with expansion:
|
||||
{ } is approx: { }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher
|
||||
Vectors with elements
|
||||
A vector is approx equal to itself
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, Approx(v1) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher
|
||||
Vectors with elements
|
||||
Different length
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, !Approx(temp) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } not is approx: { 1.0, 2.0, 3.0, 4.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher
|
||||
Vectors with elements
|
||||
Same length, different elements
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, !Approx(v2) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } not is approx: { 1.5, 2.5, 3.5 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, Approx(v2).margin(0.5) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, Approx(v2).epsilon(0.5) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( v1, Approx(v2).epsilon(0.1).scale(500) )
|
||||
with expansion:
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher -- failing
|
||||
Empty and non empty vectors are not approx equal
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( empty, Approx(t1) )
|
||||
with expansion:
|
||||
{ } is approx: { 1.0, 2.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector Approx matcher -- failing
|
||||
Just different vectors
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( v1, Approx(v2) )
|
||||
with expansion:
|
||||
{ 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Vector matchers
|
||||
Contains (element)
|
||||
@@ -11128,6 +11218,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 258 | 176 passed | 78 failed | 4 failed as expected
|
||||
assertions: 1436 | 1276 passed | 139 failed | 21 failed as expected
|
||||
test cases: 260 | 177 passed | 79 failed | 4 failed as expected
|
||||
assertions: 1445 | 1283 passed | 141 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="123" tests="1437" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="125" tests="1446" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
@@ -741,6 +741,20 @@ Exception.tests.cpp:<line number>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="Use a custom approx" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Variadic macros/Section with one argument" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher/Empty vector is roughly equal to an empty vector" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher/Vectors with elements/A vector is approx equal to itself" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher/Vectors with elements/Different length" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher/Vectors with elements/Same length, different elements" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher -- failing/Empty and non empty vectors are not approx equal" time="{duration}">
|
||||
<failure message="{ } is approx: { 1.0, 2.0 }" type="CHECK_THAT">
|
||||
Matchers.tests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="Vector Approx matcher -- failing/Just different vectors" time="{duration}">
|
||||
<failure message="{ 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 }" type="CHECK_THAT">
|
||||
Matchers.tests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<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}"/>
|
||||
|
@@ -10713,6 +10713,111 @@ Message from section two
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Vector Approx matcher" tags="[approx][matchers][vector]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Empty vector is roughly equal to an empty vector" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
empty, Approx(empty)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ } is approx: { }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Vectors with elements" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="A vector is approx equal to itself" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx(v1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResults successes="1" 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" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, !Approx(temp)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } not is approx: { 1.0, 2.0, 3.0, 4.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Vectors with elements" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Same length, different elements" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, !Approx(v2)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } not is approx: { 1.5, 2.5, 3.5 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx(v2).margin(0.5)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx(v2).epsilon(0.5)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx(v2).epsilon(0.1).scale(500)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Vector Approx matcher -- failing" tags="[.][approx][failing][matchers][vector]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Empty and non empty vectors are not approx equal" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
empty, Approx(t1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ } is approx: { 1.0, 2.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Just different vectors" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
v1, Approx(v2)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Vector matchers" tags="[matchers][vector]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="Contains (element)" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@@ -13399,7 +13504,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1276" failures="140" expectedFailures="21"/>
|
||||
<OverallResults successes="1283" failures="142" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="1276" failures="139" expectedFailures="21"/>
|
||||
<OverallResults successes="1283" failures="141" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
Reference in New Issue
Block a user