Refactor how shortcircuiting of old style matchers is tested

This commit is contained in:
Martin Hořeňovský
2020-07-26 21:31:29 +02:00
parent ac54ba7e12
commit 5ca68829e1
7 changed files with 32 additions and 32 deletions

View File

@@ -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);