mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Refactor how shortcircuiting of old style matchers is tested
This commit is contained in:
parent
ac54ba7e12
commit
5ca68829e1
@ -435,10 +435,10 @@ Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: matcher.match(1) for: true
|
||||
Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: 1, !(first && second) for: 1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
|
||||
Matchers.tests.cpp:<line number>: passed: !(matcher.match( 1 )) for: !false
|
||||
Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: 1, first || second for: 1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
|
||||
Matchers.tests.cpp:<line number>: passed: matcher.match( 1 ) for: true
|
||||
Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive)
|
||||
|
@ -3419,16 +3419,15 @@ with expansion:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Composed matchers shortcircuit
|
||||
&&
|
||||
MatchAllOf
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( 1, !(first && second) )
|
||||
CHECK_FALSE( matcher.match( 1 ) )
|
||||
with expansion:
|
||||
1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to
|
||||
fail )
|
||||
!false
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE( first.matchCalled )
|
||||
@ -3442,16 +3441,15 @@ with expansion:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Composed matchers shortcircuit
|
||||
||
|
||||
MatchAnyOf
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
CHECK_THAT( 1, first || second )
|
||||
CHECK( matcher.match( 1 ) )
|
||||
with expansion:
|
||||
1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail
|
||||
)
|
||||
true
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE( first.matchCalled )
|
||||
|
@ -392,8 +392,8 @@ Exception.tests.cpp:<line number>
|
||||
<testcase classname="<exe-name>.global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed generic matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed generic matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/&&" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/||" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run">
|
||||
<failure message="testStringForMatching(), Contains("not there", Catch::CaseSensitive::No)" type="CHECK_THAT">
|
||||
FAILED:
|
||||
|
@ -959,8 +959,8 @@ Exception.tests.cpp:<line number>
|
||||
<testCase name="Combining templated matchers" duration="{duration}"/>
|
||||
<testCase name="Composed generic matchers shortcircuit/MatchAllOf" duration="{duration}"/>
|
||||
<testCase name="Composed generic matchers shortcircuit/MatchAnyOf" duration="{duration}"/>
|
||||
<testCase name="Composed matchers shortcircuit/&&" duration="{duration}"/>
|
||||
<testCase name="Composed matchers shortcircuit/||" duration="{duration}"/>
|
||||
<testCase name="Composed matchers shortcircuit/MatchAllOf" duration="{duration}"/>
|
||||
<testCase name="Composed matchers shortcircuit/MatchAnyOf" duration="{duration}"/>
|
||||
<testCase name="Contains string matcher" duration="{duration}">
|
||||
<failure message="CHECK_THAT(testStringForMatching(), Contains("not there", Catch::CaseSensitive::No))">
|
||||
FAILED:
|
||||
|
@ -869,13 +869,13 @@ ok {test-number} - first.matchCalled for: true
|
||||
# Composed generic matchers shortcircuit
|
||||
ok {test-number} - !second.matchCalled for: true
|
||||
# Composed matchers shortcircuit
|
||||
ok {test-number} - 1, !(first && second) for: 1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
|
||||
ok {test-number} - !(matcher.match( 1 )) for: !false
|
||||
# Composed matchers shortcircuit
|
||||
ok {test-number} - first.matchCalled for: true
|
||||
# Composed matchers shortcircuit
|
||||
ok {test-number} - !second.matchCalled for: true
|
||||
# Composed matchers shortcircuit
|
||||
ok {test-number} - 1, first || second for: 1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
|
||||
ok {test-number} - matcher.match( 1 ) for: true
|
||||
# Composed matchers shortcircuit
|
||||
ok {test-number} - first.matchCalled for: true
|
||||
# Composed matchers shortcircuit
|
||||
|
@ -3769,13 +3769,13 @@ Nor would this
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Composed matchers shortcircuit" tags="[composed][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="&&" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="MatchAllOf" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_FALSE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
1, !(first && second)
|
||||
!(matcher.match( 1 ))
|
||||
</Original>
|
||||
<Expanded>
|
||||
1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
|
||||
!false
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3796,13 +3796,13 @@ Nor would this
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="||" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Section name="MatchAnyOf" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
1, first || second
|
||||
matcher.match( 1 )
|
||||
</Original>
|
||||
<Expanded>
|
||||
1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
|
@ -638,22 +638,24 @@ namespace { namespace MatchersTests {
|
||||
TEST_CASE("Composed matchers shortcircuit", "[matchers][composed]") {
|
||||
// Check that if first returns false, second is not touched
|
||||
CheckedTestingMatcher first, second;
|
||||
SECTION("&&") {
|
||||
SECTION("MatchAllOf") {
|
||||
first.matchSucceeds = false;
|
||||
// This assertion doesn't actually test anything, we just
|
||||
// want the composed matcher's `match` being called.
|
||||
CHECK_THAT(1, !(first && second));
|
||||
|
||||
Detail::MatchAllOf<int> matcher =
|
||||
Detail::MatchAllOf<int>{} && first && second;
|
||||
CHECK_FALSE( matcher.match( 1 ) );
|
||||
|
||||
// These two assertions are the important ones
|
||||
REQUIRE(first.matchCalled);
|
||||
REQUIRE(!second.matchCalled);
|
||||
}
|
||||
// Check that if first returns true, second is not touched
|
||||
SECTION("||") {
|
||||
SECTION("MatchAnyOf") {
|
||||
first.matchSucceeds = true;
|
||||
// This assertion doesn't actually test anything, we just
|
||||
// want the composed matcher's `match` being called.
|
||||
CHECK_THAT(1, first || second);
|
||||
|
||||
Detail::MatchAnyOf<int> matcher =
|
||||
Detail::MatchAnyOf<int>{} || first || second;
|
||||
CHECK( matcher.match( 1 ) );
|
||||
|
||||
// These two assertions are the important ones
|
||||
REQUIRE(first.matchCalled);
|
||||
|
Loading…
Reference in New Issue
Block a user