mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Remove obsoleted utility functions on matchers
Natural operators, &&, || and ! are preferred and do not have limited arity.
This commit is contained in:
parent
97edf7ce65
commit
a4df0b2c37
@ -17,6 +17,9 @@
|
|||||||
* `*_THROWS_AS(expr, exception_type)` now unconditionally appends `const&` to the exception type.
|
* `*_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
|
* `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.
|
* 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
|
## Improvements
|
||||||
* Reporters and Listeners can be defined in files different from the main file
|
* Reporters and Listeners can be defined in files different from the main file
|
||||||
|
@ -148,31 +148,6 @@ namespace Matchers {
|
|||||||
|
|
||||||
} // namespace Impl
|
} // namespace Impl
|
||||||
|
|
||||||
|
|
||||||
// The following functions create the actual matcher objects.
|
|
||||||
// This allows the types to be inferred
|
|
||||||
// - deprecated: prefer ||, && and !
|
|
||||||
template<typename T>
|
|
||||||
Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
|
|
||||||
return Impl::MatchNotOf<T>( underlyingMatcher );
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2 && m3;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Matchers
|
} // namespace Matchers
|
||||||
|
|
||||||
using namespace Matchers;
|
using namespace Matchers;
|
||||||
|
@ -50,16 +50,6 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
|||||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
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]")
|
TEST_CASE("Equals", "[matchers]")
|
||||||
{
|
{
|
||||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user