From cf6575576f1c5b84b9148d47e96027e39915e132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 18 Feb 2020 23:31:16 +0100 Subject: [PATCH] Start fixing up Matchers: namespaces, composition ops This commit also forbids composing lvalues of composed matchers, as per previous deprecation notice. I do not expect this to be contentious in practice, because there was a bug in that usage for years, and nobody complained. --- docs/deprecations.md | 28 ---- docs/release-notes.md | 1 + src/catch2/catch.hpp | 1 - src/catch2/catch_capture_matchers.cpp | 2 - src/catch2/catch_capture_matchers.h | 4 +- src/catch2/catch_matchers.cpp | 6 - src/catch2/catch_matchers.h | 116 ++++++++----- src/catch2/catch_matchers_templates.cpp | 8 +- src/catch2/catch_matchers_templates.hpp | 155 +++++++++--------- .../Baselines/automake.sw.approved.txt | 1 - .../Baselines/compact.sw.approved.txt | 26 ++- .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 52 ++---- .../Baselines/console.swa4.approved.txt | 2 +- .../SelfTest/Baselines/junit.sw.approved.txt | 3 +- .../Baselines/sonarqube.sw.approved.txt | 1 - tests/SelfTest/Baselines/tap.sw.approved.txt | 30 ++-- .../Baselines/teamcity.sw.approved.txt | 2 - tests/SelfTest/Baselines/xml.sw.approved.txt | 27 +-- .../SelfTest/IntrospectiveTests/Tag.tests.cpp | 3 +- .../SelfTest/UsageTests/Compilation.tests.cpp | 2 +- tests/SelfTest/UsageTests/Matchers.tests.cpp | 52 +++--- 22 files changed, 230 insertions(+), 296 deletions(-) diff --git a/docs/deprecations.md b/docs/deprecations.md index ca277d7e..c0e51b46 100644 --- a/docs/deprecations.md +++ b/docs/deprecations.md @@ -9,34 +9,6 @@ either of these is a breaking change, and thus will not happen until at least the next major release. -### Composing lvalues of already composed matchers - -Because a significant bug in this use case has persisted for 2+ years -without a bug report, and to simplify the implementation, code that -composes lvalues of composed matchers will not compile. That is, -this code will no longer work: - -```cpp - auto m1 = Contains("string"); - auto m2 = Contains("random"); - auto composed1 = m1 || m2; - auto m3 = Contains("different"); - auto composed2 = composed1 || m3; - REQUIRE_THAT(foo(), !composed1); - REQUIRE_THAT(foo(), composed2); -``` - -Instead you will have to write this: - -```cpp - auto m1 = Contains("string"); - auto m2 = Contains("random"); - auto m3 = Contains("different"); - REQUIRE_THAT(foo(), !(m1 || m2)); - REQUIRE_THAT(foo(), m1 || m2 || m3); -``` - - ## Planned changes diff --git a/docs/release-notes.md b/docs/release-notes.md index 4d385cf6..ae06c9e7 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -53,6 +53,7 @@ * The description type now must be a `const char*` or implicitly convertible to it * The `[!hide]` tag has been removed. * Use `[.]` or `[.foo]` instead. +* Lvalues of composed matchers cannot be composed further ### Fixes * The `INFO` macro no longer contains superfluous semicolon (#1456) diff --git a/src/catch2/catch.hpp b/src/catch2/catch.hpp index 7a6a7175..352eae25 100644 --- a/src/catch2/catch.hpp +++ b/src/catch2/catch.hpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/src/catch2/catch_capture_matchers.cpp b/src/catch2/catch_capture_matchers.cpp index 7ce35ef6..2b455a93 100644 --- a/src/catch2/catch_capture_matchers.cpp +++ b/src/catch2/catch_capture_matchers.cpp @@ -10,8 +10,6 @@ namespace Catch { - using StringMatcher = Matchers::Impl::MatcherBase; - // This is the general overload that takes a any string matcher // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers // the Equals matcher (so the header does not mention matchers) diff --git a/src/catch2/catch_capture_matchers.h b/src/catch2/catch_capture_matchers.h index 7ff23628..b567b8e8 100644 --- a/src/catch2/catch_capture_matchers.h +++ b/src/catch2/catch_capture_matchers.h @@ -17,7 +17,7 @@ namespace Catch { template class MatchExpr : public ITransientExpression { ArgT && m_arg; - MatcherT m_matcher; + MatcherT const& m_matcher; StringRef m_matcherString; public: MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef const& matcherString ) @@ -37,7 +37,7 @@ namespace Catch { } }; - using StringMatcher = Matchers::Impl::MatcherBase; + using StringMatcher = Matchers::MatcherBase; void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ); diff --git a/src/catch2/catch_matchers.cpp b/src/catch2/catch_matchers.cpp index df280796..7793ed06 100644 --- a/src/catch2/catch_matchers.cpp +++ b/src/catch2/catch_matchers.cpp @@ -9,7 +9,6 @@ namespace Catch { namespace Matchers { - namespace Impl { std::string MatcherUntypedBase::toString() const { if( m_cachedToString.empty() ) @@ -19,10 +18,5 @@ namespace Matchers { MatcherUntypedBase::~MatcherUntypedBase() = default; - } // namespace Impl } // namespace Matchers - -using namespace Matchers; -using Matchers::Impl::MatcherBase; - } // namespace Catch diff --git a/src/catch2/catch_matchers.h b/src/catch2/catch_matchers.h index 08b69584..78f12da9 100644 --- a/src/catch2/catch_matchers.h +++ b/src/catch2/catch_matchers.h @@ -15,11 +15,11 @@ namespace Catch { namespace Matchers { - namespace Impl { - template struct MatchAllOf; - template struct MatchAnyOf; - template struct MatchNotOf; +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif class MatcherUntypedBase { public: @@ -29,16 +29,11 @@ namespace Matchers { std::string toString() const; protected: - virtual ~MatcherUntypedBase(); + virtual ~MatcherUntypedBase(); // = default; virtual std::string describe() const = 0; mutable std::string m_cachedToString; }; -#ifdef __clang__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wnon-virtual-dtor" -#endif - template struct MatcherMethod { virtual bool match( ObjectT const& arg ) const = 0; @@ -58,16 +53,19 @@ namespace Matchers { #endif template - struct MatcherBase : MatcherUntypedBase, MatcherMethod { + struct MatcherBase : MatcherUntypedBase, MatcherMethod {}; - - MatchAllOf operator && ( MatcherBase const& other ) const; - MatchAnyOf operator || ( MatcherBase const& other ) const; - MatchNotOf operator ! () const; - }; + namespace Detail { template struct MatchAllOf : MatcherBase { + MatchAllOf() = default; + MatchAllOf(MatchAllOf const&) = delete; + MatchAllOf& operator=(MatchAllOf const&) = delete; + MatchAllOf(MatchAllOf&&) = default; + MatchAllOf& operator=(MatchAllOf&&) = default; + + bool match( ArgT const& arg ) const override { for( auto matcher : m_matchers ) { if (!matcher->match(arg)) @@ -91,16 +89,35 @@ namespace Matchers { return description; } - MatchAllOf operator && ( MatcherBase const& other ) { - auto copy(*this); - copy.m_matchers.push_back( &other ); - return copy; + friend MatchAllOf operator&& (MatchAllOf&& lhs, MatcherBase const& rhs) { + lhs.m_matchers.push_back(&rhs); + return std::move(lhs); + } + friend MatchAllOf operator&& (MatcherBase const& lhs, MatchAllOf&& rhs) { + rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs); + return std::move(rhs); } + private: std::vector const*> m_matchers; }; + + //! lvalue overload is intentionally deleted, users should + //! not be trying to compose stored composition matchers + template + MatchAllOf operator&& (MatchAllOf const& lhs, MatcherBase const& rhs) = delete; + //! lvalue overload is intentionally deleted, users should + //! not be trying to compose stored composition matchers + template + MatchAllOf operator&& (MatcherBase const& lhs, MatchAllOf const& rhs) = delete; + template struct MatchAnyOf : MatcherBase { + MatchAnyOf() = default; + MatchAnyOf(MatchAnyOf const&) = delete; + MatchAnyOf& operator=(MatchAnyOf const&) = delete; + MatchAnyOf(MatchAnyOf&&) = default; + MatchAnyOf& operator=(MatchAnyOf&&) = default; bool match( ArgT const& arg ) const override { for( auto matcher : m_matchers ) { @@ -125,19 +142,34 @@ namespace Matchers { return description; } - MatchAnyOf operator || ( MatcherBase const& other ) { - auto copy(*this); - copy.m_matchers.push_back( &other ); - return copy; + friend MatchAnyOf operator|| (MatchAnyOf&& lhs, MatcherBase const& rhs) { + lhs.m_matchers.push_back(&rhs); + return std::move(lhs); + } + friend MatchAnyOf operator|| (MatcherBase const& lhs, MatchAnyOf&& rhs) { + rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs); + return std::move(rhs); } + private: std::vector const*> m_matchers; }; + //! lvalue overload is intentionally deleted, users should + //! not be trying to compose stored composition matchers + template + MatchAnyOf operator|| (MatchAnyOf const& lhs, MatcherBase const& rhs) = delete; + //! lvalue overload is intentionally deleted, users should + //! not be trying to compose stored composition matchers + template + MatchAnyOf operator|| (MatcherBase const& lhs, MatchAnyOf const& rhs) = delete; + template struct MatchNotOf : MatcherBase { - MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + explicit MatchNotOf( MatcherBase const& underlyingMatcher ): + m_underlyingMatcher( underlyingMatcher ) + {} bool match( ArgT const& arg ) const override { return !m_underlyingMatcher.match( arg ); @@ -146,29 +178,29 @@ namespace Matchers { std::string describe() const override { return "not " + m_underlyingMatcher.toString(); } + + private: MatcherBase const& m_underlyingMatcher; }; - template - MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { - return MatchAllOf() && *this && other; - } - template - MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { - return MatchAnyOf() || *this || other; - } - template - MatchNotOf MatcherBase::operator ! () const { - return MatchNotOf( *this ); - } + } // namespace Detail + + template + Detail::MatchAllOf operator&& (MatcherBase const& lhs, MatcherBase const& rhs) { + return Detail::MatchAllOf{} && lhs && rhs; + } + template + Detail::MatchAnyOf operator|| (MatcherBase const& lhs, MatcherBase const& rhs) { + return Detail::MatchAnyOf{} || lhs || rhs; + } + + template + Detail::MatchNotOf operator! (MatcherBase const& matcher) { + return Detail::MatchNotOf{ matcher }; + } - } // namespace Impl } // namespace Matchers - -using namespace Matchers; -using Matchers::Impl::MatcherBase; - } // namespace Catch #endif // TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED diff --git a/src/catch2/catch_matchers_templates.cpp b/src/catch2/catch_matchers_templates.cpp index 16b4a685..663173f2 100644 --- a/src/catch2/catch_matchers_templates.cpp +++ b/src/catch2/catch_matchers_templates.cpp @@ -2,8 +2,9 @@ namespace Catch { namespace Matchers { - namespace Impl { - MatcherGenericBase::~MatcherGenericBase() {} + MatcherGenericBase::~MatcherGenericBase() = default; + + namespace Detail { std::string describe_multi_matcher(StringRef combine, std::string const* descriptions_begin, std::string const* descriptions_end) { std::string description; @@ -27,6 +28,7 @@ namespace Matchers { description += " )"; return description; } - } + + } // namespace Detail } // namespace Matchers } // namespace Catch diff --git a/src/catch2/catch_matchers_templates.hpp b/src/catch2/catch_matchers_templates.hpp index e1387db6..d770f25c 100644 --- a/src/catch2/catch_matchers_templates.hpp +++ b/src/catch2/catch_matchers_templates.hpp @@ -14,16 +14,12 @@ namespace Catch { namespace Matchers { - namespace Impl { + struct MatcherGenericBase : MatcherUntypedBase { + virtual ~MatcherGenericBase(); // = default; + }; - template struct MatchAllOfGeneric; - template struct MatchAnyOfGeneric; - template struct MatchNotOfGeneric; - - struct MatcherGenericBase : MatcherUntypedBase { - virtual ~MatcherGenericBase(); - }; + namespace Detail { template std::array array_cat(std::array && lhs, std::array && rhs) { std::array arr{}; @@ -63,7 +59,7 @@ namespace Matchers { template using is_generic_matcher = std::is_base_of< - Catch::Matchers::Impl::MatcherGenericBase, + Catch::Matchers::MatcherGenericBase, typename std::remove_cv::type>::type >; @@ -72,7 +68,7 @@ namespace Matchers { template using is_matcher = std::is_base_of< - Catch::Matchers::Impl::MatcherUntypedBase, + Catch::Matchers::MatcherUntypedBase, typename std::remove_cv::type>::type >; @@ -161,102 +157,101 @@ namespace Matchers { MatcherT const& m_matcher; }; + } // namespace Detail - // compose only generic matchers - template - typename std::enable_if::value, MatchAllOfGeneric>::type + + // FIXME: enable_if_t + + // compose only generic matchers + template + typename std::enable_if::value, Detail::MatchAllOfGeneric>::type operator && (MatcherLHS const& lhs, MatcherRHS const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - template - typename std::enable_if::value, MatchAnyOfGeneric>::type + template + typename std::enable_if::value, Detail::MatchAnyOfGeneric>::type operator || (MatcherLHS const& lhs, MatcherRHS const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - template - typename std::enable_if::value, MatchNotOfGeneric>::type + template + typename std::enable_if::value, Detail::MatchNotOfGeneric>::type operator ! (MatcherT const& matcher) { - return MatchNotOfGeneric{matcher}; - } + return Detail::MatchNotOfGeneric{matcher}; + } - // compose mixed generic and non-generic matchers - template - typename std::enable_if::value, MatchAllOfGeneric>>::type + // compose mixed generic and non-generic matchers + template + typename std::enable_if::value, Detail::MatchAllOfGeneric>>::type operator && (MatcherLHS const& lhs, MatcherBase const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - template - typename std::enable_if::value, MatchAllOfGeneric, MatcherRHS>>::type + template + typename std::enable_if::value, Detail::MatchAllOfGeneric, MatcherRHS>>::type operator && (MatcherBase const& lhs, MatcherRHS const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - template - typename std::enable_if::value, MatchAnyOfGeneric>>::type + template + typename std::enable_if::value, Detail::MatchAnyOfGeneric>>::type operator || (MatcherLHS const& lhs, MatcherBase const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - template - typename std::enable_if::value, MatchAnyOfGeneric, MatcherRHS>>::type + template + typename std::enable_if::value, Detail::MatchAnyOfGeneric, MatcherRHS>>::type operator || (MatcherBase const& lhs, MatcherRHS const& rhs) { - return {lhs, rhs}; - } + return { lhs, rhs }; + } - // avoid deep nesting of matcher templates - template - MatchAllOfGeneric - operator && (MatchAllOfGeneric && lhs, MatchAllOfGeneric && rhs) { - return MatchAllOfGeneric{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; - } + // avoid deep nesting of matcher templates + template + Detail::MatchAllOfGeneric + operator && (Detail::MatchAllOfGeneric&& lhs, Detail::MatchAllOfGeneric&& rhs) { + return Detail::MatchAllOfGeneric{Detail::array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; + } - template - typename std::enable_if::value, MatchAllOfGeneric>::type - operator && (MatchAllOfGeneric && lhs, MatcherRHS const& rhs) { - return MatchAllOfGeneric{array_cat(std::move(lhs.m_matchers), static_cast(&rhs))}; - } + template + typename std::enable_if::value, Detail::MatchAllOfGeneric>::type + operator && (Detail::MatchAllOfGeneric&& lhs, MatcherRHS const& rhs) { + return Detail::MatchAllOfGeneric{Detail::array_cat(std::move(lhs.m_matchers), static_cast(&rhs))}; + } - template - typename std::enable_if::value, MatchAllOfGeneric>::type - operator && (MatcherLHS const& lhs, MatchAllOfGeneric && rhs) { - return MatchAllOfGeneric{array_cat(static_cast(std::addressof(lhs)), std::move(rhs.m_matchers))}; - } + template + typename std::enable_if::value, Detail::MatchAllOfGeneric>::type + operator && (MatcherLHS const& lhs, Detail::MatchAllOfGeneric&& rhs) { + return Detail::MatchAllOfGeneric{Detail::array_cat(static_cast(std::addressof(lhs)), std::move(rhs.m_matchers))}; + } - template - MatchAnyOfGeneric - operator || (MatchAnyOfGeneric && lhs, MatchAnyOfGeneric && rhs) { - return MatchAnyOfGeneric{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; - } + template + Detail::MatchAnyOfGeneric + operator || (Detail::MatchAnyOfGeneric&& lhs, Detail::MatchAnyOfGeneric&& rhs) { + return Detail::MatchAnyOfGeneric{Detail::array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; + } - template - typename std::enable_if::value, MatchAnyOfGeneric>::type - operator || (MatchAnyOfGeneric && lhs, MatcherRHS const& rhs) { - return MatchAnyOfGeneric{array_cat(std::move(lhs.m_matchers), static_cast(std::addressof(rhs)))}; - } + template + typename std::enable_if::value, Detail::MatchAnyOfGeneric>::type + operator || (Detail::MatchAnyOfGeneric&& lhs, MatcherRHS const& rhs) { + return Detail::MatchAnyOfGeneric{Detail::array_cat(std::move(lhs.m_matchers), static_cast(std::addressof(rhs)))}; + } - template - typename std::enable_if::value, MatchAnyOfGeneric>::type - operator || (MatcherLHS const& lhs, MatchAnyOfGeneric && rhs) { - return MatchAnyOfGeneric{array_cat(static_cast(std::addressof(lhs)), std::move(rhs.m_matchers))}; - } + template + typename std::enable_if::value, Detail::MatchAnyOfGeneric>::type + operator || (MatcherLHS const& lhs, Detail::MatchAnyOfGeneric&& rhs) { + return Detail::MatchAnyOfGeneric{Detail::array_cat(static_cast(std::addressof(lhs)), std::move(rhs.m_matchers))}; + } - template - MatcherT const& operator ! (MatchNotOfGeneric const& matcher) { - return matcher.m_matcher; - } + template + MatcherT const& operator ! (Detail::MatchNotOfGeneric const& matcher) { + return matcher.m_matcher; + } - } // namespace Impl } // namespace Matchers - -using namespace Matchers; -using Matchers::Impl::MatcherGenericBase; - } // namespace Catch #endif //TWOBLUECUBES_CATCH_MATCHERS_TEMPLATES_HPP_INCLUDED diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 77e56433..db7f4006 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -99,7 +99,6 @@ Nor would this :test-result: PASS Comparisons between ints where one side is computed :test-result: PASS Comparisons between unsigned ints and negative signed ints match c++ standard behaviour :test-result: PASS Comparisons with int literals don't warn when mixing signed/ unsigned -:test-result: PASS Composed matchers are distinct :test-result: FAIL Contains string matcher :test-result: PASS Copy and then generate a range :test-result: FAIL Custom exceptions can be translated when testing for nothrow diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 6524b8fd..eb8ccc42 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -33,7 +33,7 @@ Compilation.tests.cpp:: passed: a == t for: 3 == 3 Compilation.tests.cpp:: passed: throws_int(true) Compilation.tests.cpp:: passed: throws_int(true), int Compilation.tests.cpp:: passed: throws_int(false) -Compilation.tests.cpp:: passed: "aaa", Catch::EndsWith("aaa") for: "aaa" ends with: "aaa" +Compilation.tests.cpp:: passed: "aaa", Catch::Matchers::EndsWith("aaa") for: "aaa" ends with: "aaa" Compilation.tests.cpp:: passed: templated_tests(3) for: true Misc.tests.cpp:: failed: f() == 0 for: 1 == 0 Misc.tests.cpp:: passed: errno == 1 for: 1 == 1 @@ -263,28 +263,28 @@ ToStringGeneral.tests.cpp:: passed: c == i for: 2 == 2 ToStringGeneral.tests.cpp:: passed: c == i for: 3 == 3 ToStringGeneral.tests.cpp:: passed: c == i for: 4 == 4 ToStringGeneral.tests.cpp:: passed: c == i for: 5 == 5 -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() && MatcherB() && MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() && MatcherB() && MatcherC() && MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 and equals: true ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() || MatcherB() || MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() || MatcherB() || MatcherC() || MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 or equals: true ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Detail::MatchNotOfGeneric >::value' Matchers.tests.cpp:: passed: 0, !MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!!MatcherA()), MatcherA const& >::value' Matchers.tests.cpp:: passed: 1, !!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Detail::MatchNotOfGeneric >::value' Matchers.tests.cpp:: passed: 0, !!!MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(!!!!MatcherA()), MatcherA const & >::value' Matchers.tests.cpp:: passed: 1, !!!!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf >::value' -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Detail::MatchAnyOf >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() || MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' Matchers.tests.cpp:: passed: 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 ) -Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric> >::value' +Matchers.tests.cpp:: passed: with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric> >::value' Matchers.tests.cpp:: passed: 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 ) Matchers.tests.cpp:: passed: vec, Predicate>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } ) Matchers.tests.cpp:: passed: str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" ) @@ -344,8 +344,6 @@ Condition.tests.cpp:: passed: 4 == ul for: 4 == 4 Condition.tests.cpp:: passed: 5 == c for: 5 == 5 Condition.tests.cpp:: passed: 6 == uc for: 6 == 6 Condition.tests.cpp:: passed: (std::numeric_limits::max)() > ul for: 4294967295 (0x) > 4 -Matchers.tests.cpp:: passed: testStringForMatching2(), !composed1 for: "some completely different text that contains one common word" not ( contains: "string" or contains: "random" ) -Matchers.tests.cpp:: passed: testStringForMatching2(), composed2 for: "some completely different text that contains one common word" ( contains: "string" or contains: "random" or contains: "different" ) Matchers.tests.cpp:: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) Matchers.tests.cpp:: failed: testStringForMatching(), Contains("STRING") for: "this string contains 'abc' as a substring" contains: "STRING" Generators.tests.cpp:: passed: elem % 2 == 1 for: 1 == 1 @@ -1841,7 +1839,7 @@ InternalBenchmark.tests.cpp:: passed: Timing.result == Timing.itera InternalBenchmark.tests.cpp:: passed: Timing.iterations >= time.count() for: 128 >= 100 Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' -Tag.tests.cpp:: passed: tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) for: { ., magic-tag } ( Contains: magic-tag and Contains: . ) +Tag.tests.cpp:: passed: tags, VectorContains("magic-tag"_catch_sr) && VectorContains("."_catch_sr) for: { ., magic-tag } ( Contains: magic-tag and Contains: . ) StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } StringManip.tests.cpp:: passed: splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { abc } Equals: { abc } StringManip.tests.cpp:: passed: splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { abc, def } Equals: { abc, def } diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 36d6dd94..cc6328e8 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1380,6 +1380,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 329 | 255 passed | 70 failed | 4 failed as expected -assertions: 1841 | 1689 passed | 131 failed | 21 failed as expected +test cases: 328 | 254 passed | 70 failed | 4 failed as expected +assertions: 1839 | 1687 passed | 131 failed | 21 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 0715ac7d..243ab6f9 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -271,7 +271,7 @@ Compilation.tests.cpp:: PASSED: REQUIRE_NOTHROW( throws_int(false) ) Compilation.tests.cpp:: PASSED: - REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") ) + REQUIRE_THAT( "aaa", Catch::Matchers::EndsWith("aaa") ) with expansion: "aaa" ends with: "aaa" @@ -2125,7 +2125,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: with message: std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch:: - Matchers::Impl::MatchAllOfGeneric >::value + Matchers::Detail::MatchAllOfGeneric >::value Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1, MatcherA() && MatcherB() && MatcherC() ) @@ -2136,7 +2136,7 @@ with expansion: Matchers.tests.cpp:: PASSED: with message: std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), - Catch::Matchers::Impl::MatchAllOfGeneric >::value Matchers.tests.cpp:: PASSED: @@ -2154,7 +2154,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: with message: std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch:: - Matchers::Impl::MatchAnyOfGeneric >::value + Matchers::Detail::MatchAnyOfGeneric >::value Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1, MatcherA() || MatcherB() || MatcherC() ) @@ -2165,7 +2165,7 @@ with expansion: Matchers.tests.cpp:: PASSED: with message: std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), - Catch::Matchers::Impl::MatchAnyOfGeneric >::value Matchers.tests.cpp:: PASSED: @@ -2182,8 +2182,8 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: with message: - std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric - >::value + std::is_same< decltype(!MatcherA()), Catch::Matchers::Detail:: + MatchNotOfGeneric >::value Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0, !MatcherA() ) @@ -2201,7 +2201,7 @@ with expansion: Matchers.tests.cpp:: PASSED: with message: - std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl:: + std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Detail:: MatchNotOfGeneric >::value Matchers.tests.cpp:: PASSED: @@ -2227,8 +2227,8 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: with message: std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith - ("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf - >::value + ("bar") && !EndsWith("foo"))), Catch::Matchers::Detail::MatchAnyOf >::value ------------------------------------------------------------------------------- Combining only templated matchers @@ -2238,7 +2238,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: with message: - std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl:: + std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Detail:: MatchAnyOfGeneric >::value Matchers.tests.cpp:: PASSED: @@ -2248,7 +2248,7 @@ with expansion: Matchers.tests.cpp:: PASSED: with message: - std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl:: + std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Detail:: MatchAllOfGeneric >::value Matchers.tests.cpp:: PASSED: @@ -2258,8 +2258,8 @@ with expansion: Matchers.tests.cpp:: PASSED: with message: - std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl:: - MatchAnyOfGeneric> >::value Matchers.tests.cpp:: PASSED: @@ -2610,24 +2610,6 @@ Condition.tests.cpp:: PASSED: with expansion: 4294967295 (0x) > 4 -------------------------------------------------------------------------------- -Composed matchers are distinct -------------------------------------------------------------------------------- -Matchers.tests.cpp: -............................................................................... - -Matchers.tests.cpp:: PASSED: - REQUIRE_THAT( testStringForMatching2(), !composed1 ) -with expansion: - "some completely different text that contains one common word" not ( - contains: "string" or contains: "random" ) - -Matchers.tests.cpp:: PASSED: - REQUIRE_THAT( testStringForMatching2(), composed2 ) -with expansion: - "some completely different text that contains one common word" ( contains: - "string" or contains: "random" or contains: "different" ) - ------------------------------------------------------------------------------- Contains string matcher ------------------------------------------------------------------------------- @@ -13485,7 +13467,7 @@ Tag.tests.cpp: ............................................................................... Tag.tests.cpp:: PASSED: - REQUIRE_THAT( tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) ) + REQUIRE_THAT( tags, VectorContains("magic-tag"_catch_sr) && VectorContains("."_catch_sr) ) with expansion: { ., magic-tag } ( Contains: magic-tag and Contains: . ) @@ -14414,6 +14396,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 329 | 239 passed | 86 failed | 4 failed as expected -assertions: 1858 | 1689 passed | 148 failed | 21 failed as expected +test cases: 328 | 238 passed | 86 failed | 4 failed as expected +assertions: 1856 | 1687 passed | 148 failed | 21 failed as expected diff --git a/tests/SelfTest/Baselines/console.swa4.approved.txt b/tests/SelfTest/Baselines/console.swa4.approved.txt index 72d87375..f8c59c90 100644 --- a/tests/SelfTest/Baselines/console.swa4.approved.txt +++ b/tests/SelfTest/Baselines/console.swa4.approved.txt @@ -271,7 +271,7 @@ Compilation.tests.cpp:: PASSED: REQUIRE_NOTHROW( throws_int(false) ) Compilation.tests.cpp:: PASSED: - REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") ) + REQUIRE_THAT( "aaa", Catch::Matchers::EndsWith("aaa") ) with expansion: "aaa" ends with: "aaa" diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index e5b297ef..f3d7ba04 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -364,7 +364,6 @@ Exception.tests.cpp: - FAILED: diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index ee917244..c554f8d9 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -925,7 +925,6 @@ Exception.tests.cpp: - FAILED: diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 58869cfb..85a67157 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -65,7 +65,7 @@ ok {test-number} - throws_int(true), int # #833 ok {test-number} - throws_int(false) # #833 -ok {test-number} - "aaa", Catch::EndsWith("aaa") for: "aaa" ends with: "aaa" +ok {test-number} - "aaa", Catch::Matchers::EndsWith("aaa") for: "aaa" ends with: "aaa" # #833 ok {test-number} - templated_tests(3) for: true # #835 -- errno should not be touched by Catch @@ -525,23 +525,23 @@ ok {test-number} - c == i for: 4 == 4 # Character pretty printing ok {test-number} - c == i for: 5 == 5 # Combining MatchAllOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' # Combining MatchAllOfGeneric does not nest ok {test-number} - 1, MatcherA() && MatcherB() && MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 ) # Combining MatchAllOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' # Combining MatchAllOfGeneric does not nest ok {test-number} - 1, MatcherA() && MatcherB() && MatcherC() && MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 and equals: true ) # Combining MatchAnyOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' # Combining MatchAnyOfGeneric does not nest ok {test-number} - 1, MatcherA() || MatcherB() || MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 ) # Combining MatchAnyOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' # Combining MatchAnyOfGeneric does not nest ok {test-number} - 1, MatcherA() || MatcherB() || MatcherC() || MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 or equals: true ) # Combining MatchNotOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Detail::MatchNotOfGeneric >::value' # Combining MatchNotOfGeneric does not nest ok {test-number} - 0, !MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f # Combining MatchNotOfGeneric does not nest @@ -549,7 +549,7 @@ ok {test-number} - with 1 message: 'std::is_same< decltype(!!MatcherA()), Matche # Combining MatchNotOfGeneric does not nest ok {test-number} - 1, !!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f # Combining MatchNotOfGeneric does not nest -ok {test-number} - with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Detail::MatchNotOfGeneric >::value' # Combining MatchNotOfGeneric does not nest ok {test-number} - 0, !!!MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f # Combining MatchNotOfGeneric does not nest @@ -557,17 +557,17 @@ ok {test-number} - with 1 message: 'std::is_same< decltype(!!!!MatcherA()), Matc # Combining MatchNotOfGeneric does not nest ok {test-number} - 1, !!!!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f # Combining concrete matchers does not use templated matchers -ok {test-number} - with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Detail::MatchAnyOf >::value' # Combining only templated matchers -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric >::value' # Combining only templated matchers ok {test-number} - 1, MatcherA() || MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 ) # Combining only templated matchers -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl::MatchAllOfGeneric >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Detail::MatchAllOfGeneric >::value' # Combining only templated matchers ok {test-number} - 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 ) # Combining only templated matchers -ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric> >::value' +ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric> >::value' # Combining only templated matchers ok {test-number} - 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 ) # Combining templated and concrete matchers @@ -686,10 +686,6 @@ ok {test-number} - 5 == c for: 5 == 5 ok {test-number} - 6 == uc for: 6 == 6 # Comparisons with int literals don't warn when mixing signed/ unsigned ok {test-number} - (std::numeric_limits::max)() > ul for: 4294967295 (0x) > 4 -# Composed matchers are distinct -ok {test-number} - testStringForMatching2(), !composed1 for: "some completely different text that contains one common word" not ( contains: "string" or contains: "random" ) -# Composed matchers are distinct -ok {test-number} - testStringForMatching2(), composed2 for: "some completely different text that contains one common word" ( contains: "string" or contains: "random" or contains: "different" ) # Contains string matcher not ok {test-number} - testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) # Contains string matcher @@ -3509,7 +3505,7 @@ not ok {test-number} - false with 1 message: '3' # sends information to INFO not ok {test-number} - false with 2 messages: 'hi' and 'i := 7' # shortened hide tags are split apart -ok {test-number} - tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) for: { ., magic-tag } ( Contains: magic-tag and Contains: . ) +ok {test-number} - tags, VectorContains("magic-tag"_catch_sr) && VectorContains("."_catch_sr) for: { ., magic-tag } ( Contains: magic-tag and Contains: . ) # splitString ok {test-number} - splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } # splitString @@ -3708,5 +3704,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..1850 +1..1848 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index e3d1ead2..dbfb9835 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -231,8 +231,6 @@ Exception.tests.cpp:|nunexpected exception with message:|n "unexpe ##teamcity[testFinished name='Comparisons between unsigned ints and negative signed ints match c++ standard behaviour' duration="{duration}"] ##teamcity[testStarted name='Comparisons with int literals don|'t warn when mixing signed/ unsigned'] ##teamcity[testFinished name='Comparisons with int literals don|'t warn when mixing signed/ unsigned' duration="{duration}"] -##teamcity[testStarted name='Composed matchers are distinct'] -##teamcity[testFinished name='Composed matchers are distinct' duration="{duration}"] ##teamcity[testStarted name='Contains string matcher'] Matchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "not there" (case insensitive)|n'] Matchers.tests.cpp:|nexpression failed|n CHECK_THAT( testStringForMatching(), Contains("STRING") )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "STRING"|n'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 3caf2c19..bbd37d53 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -299,7 +299,7 @@ Nor would this - "aaa", Catch::EndsWith("aaa") + "aaa", Catch::Matchers::EndsWith("aaa") "aaa" ends with: "aaa" @@ -3011,25 +3011,6 @@ Nor would this - - - - testStringForMatching2(), !composed1 - - - "some completely different text that contains one common word" not ( contains: "string" or contains: "random" ) - - - - - testStringForMatching2(), composed2 - - - "some completely different text that contains one common word" ( contains: "string" or contains: "random" or contains: "different" ) - - - - @@ -16273,7 +16254,7 @@ loose text artifact - tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr) + tags, VectorContains("magic-tag"_catch_sr) && VectorContains("."_catch_sr) { ., magic-tag } ( Contains: magic-tag and Contains: . ) @@ -17283,7 +17264,7 @@ loose text artifact - + - + diff --git a/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp b/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp index 6f27ad8c..7b1f4857 100644 --- a/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp @@ -41,11 +41,12 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) { TEST_CASE("shortened hide tags are split apart") { using Catch::StringRef; + using Catch::Matchers::VectorContains; auto testcase = Catch::makeTestCaseInfo("", {"fake test name", "[.magic-tag]"}, CATCH_INTERNAL_LINEINFO); // Transform ... std::vector tags; for (auto const& tag : testcase->tags) { tags.push_back(tag.original); } - REQUIRE_THAT(tags, Catch::VectorContains("magic-tag"_catch_sr) && Catch::VectorContains("."_catch_sr)); + REQUIRE_THAT(tags, VectorContains("magic-tag"_catch_sr) && VectorContains("."_catch_sr)); } diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index b34bdfbd..2b0ef0b9 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -79,7 +79,7 @@ namespace { namespace CompilationTests { REQUIRE_THROWS(throws_int(true)); CHECK_THROWS_AS(throws_int(true), int); REQUIRE_NOTHROW(throws_int(false)); - REQUIRE_THAT("aaa", Catch::EndsWith("aaa")); + REQUIRE_THAT("aaa", Catch::Matchers::EndsWith("aaa")); return true; } diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index e5c28ef9..0333a457 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -78,7 +78,7 @@ namespace { namespace MatchersTests { throw DerivedException{}; } - class ExceptionMatcher : public Catch::MatcherBase { + class ExceptionMatcher : public Catch::Matchers::MatcherBase { int m_expected; public: ExceptionMatcher(int i) : m_expected(i) {} @@ -556,19 +556,8 @@ namespace { namespace MatchersTests { REQUIRE_THROWS_MATCHES(throwsSpecialException(2), SpecialException, Message("SpecialException::what")); } - TEST_CASE("Composed matchers are distinct", "[matchers][composed]") { - auto m1 = Contains("string"); - auto m2 = Contains("random"); - auto composed1 = m1 || m2; - auto m3 = Contains("different"); - auto composed2 = composed1 || m3; - REQUIRE_THAT(testStringForMatching2(), !composed1); - REQUIRE_THAT(testStringForMatching2(), composed2); - } - - template - struct EqualsRangeMatcher : Catch::MatcherGenericBase { + struct EqualsRangeMatcher : Catch::Matchers::MatcherGenericBase { EqualsRangeMatcher(Range const& range) : range{ range } {} @@ -604,7 +593,6 @@ namespace { namespace MatchersTests { } TEST_CASE("Combining templated and concrete matchers", "[matchers][templated]") { - using namespace Catch::Matchers; std::vector vec{ 1, 3, 5 }; std::array a{{ 5, 3, 1 }}; @@ -640,28 +628,28 @@ namespace { namespace MatchersTests { STATIC_REQUIRE(std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), - Catch::Matchers::Impl::MatchAnyOf + Catch::Matchers::Detail::MatchAnyOf >::value); } - struct MatcherA : Catch::MatcherGenericBase { + struct MatcherA : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "equals: (int) 1 or (float) 1.0f"; } bool match(int i) const { return i == 1; } bool match(float f) const { return f == 1.0f; } }; - struct MatcherB : Catch::MatcherGenericBase { + struct MatcherB : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "equals: (long long) 1"; } bool match(long long l) const { return l == 1ll; } }; - struct MatcherC : Catch::MatcherGenericBase { + struct MatcherC : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "equals: (T) 1"; } template bool match(T t) const { return t == T{1}; } }; - struct MatcherD : Catch::MatcherGenericBase { + struct MatcherD : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "equals: true"; } bool match(bool b) const { return b == true; } }; @@ -669,21 +657,21 @@ namespace { namespace MatchersTests { TEST_CASE("Combining only templated matchers", "[matchers][templated]") { STATIC_REQUIRE(std::is_same< decltype(MatcherA() || MatcherB()), - Catch::Matchers::Impl::MatchAnyOfGeneric + Catch::Matchers::Detail::MatchAnyOfGeneric >::value); REQUIRE_THAT(1, MatcherA() || MatcherB()); STATIC_REQUIRE(std::is_same< decltype(MatcherA() && MatcherB()), - Catch::Matchers::Impl::MatchAllOfGeneric + Catch::Matchers::Detail::MatchAllOfGeneric >::value); REQUIRE_THAT(1, MatcherA() && MatcherB()); STATIC_REQUIRE(std::is_same< decltype(MatcherA() || !MatcherB()), - Catch::Matchers::Impl::MatchAnyOfGeneric> + Catch::Matchers::Detail::MatchAnyOfGeneric> >::value); REQUIRE_THAT(1, MatcherA() || !MatcherB()); @@ -692,14 +680,14 @@ namespace { namespace MatchersTests { TEST_CASE("Combining MatchAnyOfGeneric does not nest", "[matchers][templated]") { STATIC_REQUIRE(std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), - Catch::Matchers::Impl::MatchAnyOfGeneric + Catch::Matchers::Detail::MatchAnyOfGeneric >::value); REQUIRE_THAT(1, MatcherA() || MatcherB() || MatcherC()); STATIC_REQUIRE(std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), - Catch::Matchers::Impl::MatchAnyOfGeneric + Catch::Matchers::Detail::MatchAnyOfGeneric >::value); REQUIRE_THAT(1, MatcherA() || MatcherB() || MatcherC() || MatcherD()); @@ -708,14 +696,14 @@ namespace { namespace MatchersTests { TEST_CASE("Combining MatchAllOfGeneric does not nest", "[matchers][templated]") { STATIC_REQUIRE(std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), - Catch::Matchers::Impl::MatchAllOfGeneric + Catch::Matchers::Detail::MatchAllOfGeneric >::value); REQUIRE_THAT(1, MatcherA() && MatcherB() && MatcherC()); STATIC_REQUIRE(std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), - Catch::Matchers::Impl::MatchAllOfGeneric + Catch::Matchers::Detail::MatchAllOfGeneric >::value); REQUIRE_THAT(1, MatcherA() && MatcherB() && MatcherC() && MatcherD()); @@ -724,7 +712,7 @@ namespace { namespace MatchersTests { TEST_CASE("Combining MatchNotOfGeneric does not nest", "[matchers][templated]") { STATIC_REQUIRE(std::is_same< decltype(!MatcherA()), - Catch::Matchers::Impl::MatchNotOfGeneric + Catch::Matchers::Detail::MatchNotOfGeneric >::value); REQUIRE_THAT(0, !MatcherA()); @@ -738,7 +726,7 @@ namespace { namespace MatchersTests { STATIC_REQUIRE(std::is_same< decltype(!!!MatcherA()), - Catch::Matchers::Impl::MatchNotOfGeneric + Catch::Matchers::Detail::MatchNotOfGeneric >::value); REQUIRE_THAT(0, !!!MatcherA()); @@ -765,7 +753,7 @@ namespace { namespace MatchersTests { } }; - struct EvilMatcher : Catch::MatcherGenericBase { + struct EvilMatcher : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "equals: 45"; } @@ -790,7 +778,7 @@ namespace { namespace MatchersTests { REQUIRE_NOTHROW((EvilMatcher() && EvilMatcher()) || !EvilMatcher()); } - struct ImmovableMatcher : Catch::MatcherGenericBase { + struct ImmovableMatcher : Catch::Matchers::MatcherGenericBase { ImmovableMatcher() = default; ImmovableMatcher(ImmovableMatcher const&) = delete; ImmovableMatcher(ImmovableMatcher &&) = delete; @@ -814,7 +802,7 @@ namespace { namespace MatchersTests { } }; - struct ThrowOnCopyOrMoveMatcher : Catch::MatcherGenericBase { + struct ThrowOnCopyOrMoveMatcher : Catch::Matchers::MatcherGenericBase { ThrowOnCopyOrMoveMatcher() = default; [[noreturn]] ThrowOnCopyOrMoveMatcher(ThrowOnCopyOrMoveMatcher const&) { @@ -849,7 +837,7 @@ namespace { namespace MatchersTests { REQUIRE_THAT(123, (ImmovableMatcher() && ImmovableMatcher()) || !ImmovableMatcher()); } - struct ReferencingMatcher : Catch::MatcherGenericBase { + struct ReferencingMatcher : Catch::Matchers::MatcherGenericBase { std::string describe() const override { return "takes reference"; }