diff options
| author | Martin Hořeňovský | 2020-07-26 21:31:29 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-07-26 21:31:29 +0200 |
| commit | 5ca68829e10cc28471d2340439b53a41e8ff4e63 (patch) | |
| tree | 7b223ca9220ee3b7038cade14356b46a34008345 /tests/SelfTest/UsageTests | |
| parent | ac54ba7e12b77a4d88a42ee19cb193c4bd3c33ad (diff) | |
| download | catch3-5ca68829e10cc28471d2340439b53a41e8ff4e63.tar.gz | |
Refactor how shortcircuiting of old style matchers is tested
Diffstat (limited to 'tests/SelfTest/UsageTests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Matchers.tests.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index 8276cf84..b627d4a9 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/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); |