From a4df0b2c37f4f474aa0c379c484659300d315def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 30 Aug 2017 19:16:25 +0200 Subject: [PATCH] Remove obsoleted utility functions on matchers Natural operators, &&, || and ! are preferred and do not have limited arity. --- docs/release-notes.md | 3 +++ include/internal/catch_matchers.hpp | 25 ------------------------- projects/SelfTest/MatchersTests.cpp | 10 ---------- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index aa8f4957..c790e066 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -17,6 +17,9 @@ * `*_THROWS_AS(expr, exception_type)` now unconditionally appends `const&` to the exception type. * `CATCH_CONFIG_FAST_COMPILE` now affects the `CHECK_` family of assertions as well as `REQUIRE_` family of assertions * This is most noticeable in `CHECK(throws())`, which would previously report failure, properly stringify the exception and continue. Now it will report failure and stop executing current section. +* Removed deprecated matcher utility functions `Not`, `AllOf` and `AnyOf`. + * They are superseded by operators `!`, `&&` and `||`, which are natural and do not have limited arity + ## Improvements * Reporters and Listeners can be defined in files different from the main file diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index 5a3f0818..91923831 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -148,31 +148,6 @@ namespace Matchers { } // namespace Impl - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - // - deprecated: prefer ||, && and ! - template - Impl::MatchNotOf Not( Impl::MatcherBase const& underlyingMatcher ) { - return Impl::MatchNotOf( underlyingMatcher ); - } - template - Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAllOf() && m1 && m2; - } - template - Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAllOf() && m1 && m2 && m3; - } - template - Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAnyOf() || m1 || m2; - } - template - Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAnyOf() || m1 || m2 || m3; - } - } // namespace Matchers using namespace Matchers; diff --git a/projects/SelfTest/MatchersTests.cpp b/projects/SelfTest/MatchersTests.cpp index 52a49230..0482ed43 100644 --- a/projects/SelfTest/MatchersTests.cpp +++ b/projects/SelfTest/MatchersTests.cpp @@ -50,16 +50,6 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]") CHECK_THAT( testStringForMatching(), Equals( "something else" ) ); } -TEST_CASE("AllOf matcher", "[matchers]") -{ - CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) ); -} -TEST_CASE("AnyOf matcher", "[matchers]") -{ - CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) ); - CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) ); -} - TEST_CASE("Equals", "[matchers]") { CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );