Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-02-18 23:31:16 +0100
committerMartin Hořeňovský2020-02-20 13:03:30 +0100
commitcf6575576f1c5b84b9148d47e96027e39915e132 (patch)
treef756264c02c5915c6d276dfb8ccbf2fe2cd231d0
parenta1be19aa1bfcabcbd28e442c0878c1a9468e83e5 (diff)
downloadcatch3-cf6575576f1c5b84b9148d47e96027e39915e132.tar.gz
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.
-rw-r--r--docs/deprecations.md28
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/catch2/catch.hpp1
-rw-r--r--src/catch2/catch_capture_matchers.cpp2
-rw-r--r--src/catch2/catch_capture_matchers.h4
-rw-r--r--src/catch2/catch_matchers.cpp6
-rw-r--r--src/catch2/catch_matchers.h114
-rw-r--r--src/catch2/catch_matchers_templates.cpp8
-rw-r--r--src/catch2/catch_matchers_templates.hpp171
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt26
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt52
-rw-r--r--tests/SelfTest/Baselines/console.swa4.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt30
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt27
-rw-r--r--tests/SelfTest/IntrospectiveTests/Tag.tests.cpp3
-rw-r--r--tests/SelfTest/UsageTests/Compilation.tests.cpp2
-rw-r--r--tests/SelfTest/UsageTests/Matchers.tests.cpp52
22 files changed, 237 insertions, 303 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 <catch2/catch_compiler_capabilities.h>
#include <catch2/catch_string_manip.h>
-#include <catch2/catch_capture_matchers.h>
#include <catch2/catch_generators.hpp>
#include <catch2/catch_generators_generic.hpp>
#include <catch2/catch_generators_specific.hpp>
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<std::string>;
-
// 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<typename ArgT, typename MatcherT>
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<std::string>;
+ using StringMatcher = Matchers::MatcherBase<std::string>;
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<typename ArgT> struct MatchAllOf;
- template<typename ArgT> struct MatchAnyOf;
- template<typename ArgT> 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<typename ObjectT>
struct MatcherMethod {
virtual bool match( ObjectT const& arg ) const = 0;
@@ -58,16 +53,19 @@ namespace Matchers {
#endif
template<typename T>
- struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {
+ struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {};
-
- MatchAllOf<T> operator && ( MatcherBase const& other ) const;
- MatchAnyOf<T> operator || ( MatcherBase const& other ) const;
- MatchNotOf<T> operator ! () const;
- };
+ namespace Detail {
template<typename ArgT>
struct MatchAllOf : MatcherBase<ArgT> {
+ 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<ArgT> operator && ( MatcherBase<ArgT> const& other ) {
- auto copy(*this);
- copy.m_matchers.push_back( &other );
- return copy;
+ friend MatchAllOf operator&& (MatchAllOf&& lhs, MatcherBase<ArgT> const& rhs) {
+ lhs.m_matchers.push_back(&rhs);
+ return std::move(lhs);
+ }
+ friend MatchAllOf operator&& (MatcherBase<ArgT> const& lhs, MatchAllOf&& rhs) {
+ rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
+ return std::move(rhs);
}
+ private:
std::vector<MatcherBase<ArgT> const*> m_matchers;
};
+
+ //! lvalue overload is intentionally deleted, users should
+ //! not be trying to compose stored composition matchers
+ template<typename ArgT>
+ MatchAllOf<ArgT> operator&& (MatchAllOf<ArgT> const& lhs, MatcherBase<ArgT> const& rhs) = delete;
+ //! lvalue overload is intentionally deleted, users should
+ //! not be trying to compose stored composition matchers
+ template<typename ArgT>
+ MatchAllOf<ArgT> operator&& (MatcherBase<ArgT> const& lhs, MatchAllOf<ArgT> const& rhs) = delete;
+
template<typename ArgT>
struct MatchAnyOf : MatcherBase<ArgT> {
+ 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<ArgT> operator || ( MatcherBase<ArgT> const& other ) {
- auto copy(*this);
- copy.m_matchers.push_back( &other );
- return copy;
+ friend MatchAnyOf operator|| (MatchAnyOf&& lhs, MatcherBase<ArgT> const& rhs) {
+ lhs.m_matchers.push_back(&rhs);
+ return std::move(lhs);
+ }
+ friend MatchAnyOf operator|| (MatcherBase<ArgT> const& lhs, MatchAnyOf&& rhs) {
+ rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
+ return std::move(rhs);
}
+ private:
std::vector<MatcherBase<ArgT> const*> m_matchers;
};
+ //! lvalue overload is intentionally deleted, users should
+ //! not be trying to compose stored composition matchers
+ template<typename ArgT>
+ MatchAnyOf<ArgT> operator|| (MatchAnyOf<ArgT> const& lhs, MatcherBase<ArgT> const& rhs) = delete;
+ //! lvalue overload is intentionally deleted, users should
+ //! not be trying to compose stored composition matchers
+ template<typename ArgT>
+ MatchAnyOf<ArgT> operator|| (MatcherBase<ArgT> const& lhs, MatchAnyOf<ArgT> const& rhs) = delete;
+
template<typename ArgT>
struct MatchNotOf : MatcherBase<ArgT> {
- MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {}
+ explicit MatchNotOf( MatcherBase<ArgT> 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<ArgT> const& m_underlyingMatcher;
};
- template<typename T>
- MatchAllOf<T> MatcherBase<T>::operator && ( MatcherBase const& other ) const {
- return MatchAllOf<T>() && *this && other;
- }
- template<typename T>
- MatchAnyOf<T> MatcherBase<T>::operator || ( MatcherBase const& other ) const {
- return MatchAnyOf<T>() || *this || other;
- }
- template<typename T>
- MatchNotOf<T> MatcherBase<T>::operator ! () const {
- return MatchNotOf<T>( *this );
- }
+ } // namespace Detail
- } // namespace Impl
+ template <typename T>
+ Detail::MatchAllOf<T> operator&& (MatcherBase<T> const& lhs, MatcherBase<T> const& rhs) {
+ return Detail::MatchAllOf<T>{} && lhs && rhs;
+ }
+ template <typename T>
+ Detail::MatchAnyOf<T> operator|| (MatcherBase<T> const& lhs, MatcherBase<T> const& rhs) {
+ return Detail::MatchAnyOf<T>{} || lhs || rhs;
+ }
-} // namespace Matchers
+ template <typename T>
+ Detail::MatchNotOf<T> operator! (MatcherBase<T> const& matcher) {
+ return Detail::MatchNotOf<T>{ matcher };
+ }
-using namespace Matchers;
-using Matchers::Impl::MatcherBase;
+} // namespace Matchers
} // 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<typename... MatcherTs> struct MatchAllOfGeneric;
- template<typename... MatcherTs> struct MatchAnyOfGeneric;
- template<typename MatcherT> struct MatchNotOfGeneric;
-
- struct MatcherGenericBase : MatcherUntypedBase {
- virtual ~MatcherGenericBase();
- };
+ namespace Detail {
template<std::size_t N, std::size_t M>
std::array<void const*, N + M> array_cat(std::array<void const*, N> && lhs, std::array<void const*, M> && rhs) {
std::array<void const*, N + M> arr{};
@@ -63,7 +59,7 @@ namespace Matchers {
template<typename T>
using is_generic_matcher = std::is_base_of<
- Catch::Matchers::Impl::MatcherGenericBase,
+ Catch::Matchers::MatcherGenericBase,
typename std::remove_cv<typename std::remove_reference<T>::type>::type
>;
@@ -72,7 +68,7 @@ namespace Matchers {
template<typename T>
using is_matcher = std::is_base_of<
- Catch::Matchers::Impl::MatcherUntypedBase,
+ Catch::Matchers::MatcherUntypedBase,
typename std::remove_cv<typename std::remove_reference<T>::type>::type
>;
@@ -161,102 +157,101 @@ namespace Matchers {
MatcherT const& m_matcher;
};
+ } // namespace Detail
+
+
+ // FIXME: enable_if_t
- // compose only generic matchers
- template<typename MatcherLHS, typename MatcherRHS>
- typename std::enable_if<are_generic_matchers<MatcherLHS, MatcherRHS>::value, MatchAllOfGeneric<MatcherLHS, MatcherRHS>>::type
+ // compose only generic matchers
+ template<typename MatcherLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::are_generic_matchers<MatcherLHS, MatcherRHS>::value, Detail::MatchAllOfGeneric<MatcherLHS, MatcherRHS>>::type
operator && (MatcherLHS const& lhs, MatcherRHS const& rhs) {
- return {lhs, rhs};
- }
+ return { lhs, rhs };
+ }
- template<typename MatcherLHS, typename MatcherRHS>
- typename std::enable_if<are_generic_matchers<MatcherLHS, MatcherRHS>::value, MatchAnyOfGeneric<MatcherLHS, MatcherRHS>>::type
+ template<typename MatcherLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::are_generic_matchers<MatcherLHS, MatcherRHS>::value, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherRHS>>::type
operator || (MatcherLHS const& lhs, MatcherRHS const& rhs) {
- return {lhs, rhs};
- }
+ return { lhs, rhs };
+ }
- template<typename MatcherT>
- typename std::enable_if<is_generic_matcher<MatcherT>::value, MatchNotOfGeneric<MatcherT>>::type
+ template<typename MatcherT>
+ typename std::enable_if<Detail::is_generic_matcher<MatcherT>::value, Detail::MatchNotOfGeneric<MatcherT>>::type
operator ! (MatcherT const& matcher) {
- return MatchNotOfGeneric<MatcherT>{matcher};
- }
+ return Detail::MatchNotOfGeneric<MatcherT>{matcher};
+ }
- // compose mixed generic and non-generic matchers
- template<typename MatcherLHS, typename ArgRHS>
- typename std::enable_if<is_generic_matcher<MatcherLHS>::value, MatchAllOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>::type
+ // compose mixed generic and non-generic matchers
+ template<typename MatcherLHS, typename ArgRHS>
+ typename std::enable_if<Detail::is_generic_matcher<MatcherLHS>::value, Detail::MatchAllOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>::type
operator && (MatcherLHS const& lhs, MatcherBase<ArgRHS> const& rhs) {
- return {lhs, rhs};
- }
+ return { lhs, rhs };
+ }
- template<typename ArgLHS, typename MatcherRHS>
- typename std::enable_if<is_generic_matcher<MatcherRHS>::value, MatchAllOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>::type
+ template<typename ArgLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::is_generic_matcher<MatcherRHS>::value, Detail::MatchAllOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>::type
operator && (MatcherBase<ArgLHS> const& lhs, MatcherRHS const& rhs) {
- return {lhs, rhs};
- }
+ return { lhs, rhs };
+ }
- template<typename MatcherLHS, typename ArgRHS>
- typename std::enable_if<is_generic_matcher<MatcherLHS>::value, MatchAnyOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>::type
+ template<typename MatcherLHS, typename ArgRHS>
+ typename std::enable_if<Detail::is_generic_matcher<MatcherLHS>::value, Detail::MatchAnyOfGeneric<MatcherLHS, MatcherBase<ArgRHS>>>::type
operator || (MatcherLHS const& lhs, MatcherBase<ArgRHS> const& rhs) {
- return {lhs, rhs};
- }
+ return { lhs, rhs };
+ }
- template<typename ArgLHS, typename MatcherRHS>
- typename std::enable_if<is_generic_matcher<MatcherRHS>::value, MatchAnyOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>::type
+ template<typename ArgLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::is_generic_matcher<MatcherRHS>::value, Detail::MatchAnyOfGeneric<MatcherBase<ArgLHS>, MatcherRHS>>::type
operator || (MatcherBase<ArgLHS> const& lhs, MatcherRHS const& rhs) {
- return {lhs, rhs};
- }
-
-
- // avoid deep nesting of matcher templates
- template<typename... MatchersLHS, typename... MatchersRHS>
- MatchAllOfGeneric<MatchersLHS..., MatchersRHS...>
- operator && (MatchAllOfGeneric<MatchersLHS...> && lhs, MatchAllOfGeneric<MatchersRHS...> && rhs) {
- return MatchAllOfGeneric<MatchersLHS..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
- }
+ return { lhs, rhs };
+ }
+
+
+ // avoid deep nesting of matcher templates
+ template<typename... MatchersLHS, typename... MatchersRHS>
+ Detail::MatchAllOfGeneric<MatchersLHS..., MatchersRHS...>
+ operator && (Detail::MatchAllOfGeneric<MatchersLHS...>&& lhs, Detail::MatchAllOfGeneric<MatchersRHS...>&& rhs) {
+ return Detail::MatchAllOfGeneric<MatchersLHS..., MatchersRHS...>{Detail::array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
+ }
+
+ template<typename... MatchersLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::is_matcher<MatcherRHS>::value, Detail::MatchAllOfGeneric<MatchersLHS..., MatcherRHS>>::type
+ operator && (Detail::MatchAllOfGeneric<MatchersLHS...>&& lhs, MatcherRHS const& rhs) {
+ return Detail::MatchAllOfGeneric<MatchersLHS..., MatcherRHS>{Detail::array_cat(std::move(lhs.m_matchers), static_cast<void const*>(&rhs))};
+ }
+
+ template<typename MatcherLHS, typename... MatchersRHS>
+ typename std::enable_if<Detail::is_matcher<MatcherLHS>::value, Detail::MatchAllOfGeneric<MatcherLHS, MatchersRHS...>>::type
+ operator && (MatcherLHS const& lhs, Detail::MatchAllOfGeneric<MatchersRHS...>&& rhs) {
+ return Detail::MatchAllOfGeneric<MatcherLHS, MatchersRHS...>{Detail::array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
+ }
+
+ template<typename... MatchersLHS, typename... MatchersRHS>
+ Detail::MatchAnyOfGeneric<MatchersLHS..., MatchersRHS...>
+ operator || (Detail::MatchAnyOfGeneric<MatchersLHS...>&& lhs, Detail::MatchAnyOfGeneric<MatchersRHS...>&& rhs) {
+ return Detail::MatchAnyOfGeneric<MatchersLHS..., MatchersRHS...>{Detail::array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
+ }
+
+ template<typename... MatchersLHS, typename MatcherRHS>
+ typename std::enable_if<Detail::is_matcher<MatcherRHS>::value, Detail::MatchAnyOfGeneric<MatchersLHS..., MatcherRHS>>::type
+ operator || (Detail::MatchAnyOfGeneric<MatchersLHS...>&& lhs, MatcherRHS const& rhs) {
+ return Detail::MatchAnyOfGeneric<MatchersLHS..., MatcherRHS>{Detail::array_cat(std::move(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))};
+ }
+
+ template<typename MatcherLHS, typename... MatchersRHS>
+ typename std::enable_if<Detail::is_matcher<MatcherLHS>::value, Detail::MatchAnyOfGeneric<MatcherLHS, MatchersRHS...>>::type
+ operator || (MatcherLHS const& lhs, Detail::MatchAnyOfGeneric<MatchersRHS...>&& rhs) {
+ return Detail::MatchAnyOfGeneric<MatcherLHS, MatchersRHS...>{Detail::array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
+ }
+
+ template<typename MatcherT>
+ MatcherT const& operator ! (Detail::MatchNotOfGeneric<MatcherT> const& matcher) {
+ return matcher.m_matcher;
+ }
- template<typename... MatchersLHS, typename MatcherRHS>
- typename std::enable_if<is_matcher<MatcherRHS>::value, MatchAllOfGeneric<MatchersLHS..., MatcherRHS>>::type
- operator && (MatchAllOfGeneric<MatchersLHS...> && lhs, MatcherRHS const& rhs) {
- return MatchAllOfGeneric<MatchersLHS..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(&rhs))};
- }
-
- template<typename MatcherLHS, typename... MatchersRHS>
- typename std::enable_if<is_matcher<MatcherLHS>::value, MatchAllOfGeneric<MatcherLHS, MatchersRHS...>>::type
- operator && (MatcherLHS const& lhs, MatchAllOfGeneric<MatchersRHS...> && rhs) {
- return MatchAllOfGeneric<MatcherLHS, MatchersRHS...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
- }
-
- template<typename... MatchersLHS, typename... MatchersRHS>
- MatchAnyOfGeneric<MatchersLHS..., MatchersRHS...>
- operator || (MatchAnyOfGeneric<MatchersLHS...> && lhs, MatchAnyOfGeneric<MatchersRHS...> && rhs) {
- return MatchAnyOfGeneric<MatchersLHS..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
- }
-
- template<typename... MatchersLHS, typename MatcherRHS>
- typename std::enable_if<is_matcher<MatcherRHS>::value, MatchAnyOfGeneric<MatchersLHS..., MatcherRHS>>::type
- operator || (MatchAnyOfGeneric<MatchersLHS...> && lhs, MatcherRHS const& rhs) {
- return MatchAnyOfGeneric<MatchersLHS..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))};
- }
-
- template<typename MatcherLHS, typename... MatchersRHS>
- typename std::enable_if<is_matcher<MatcherLHS>::value, MatchAnyOfGeneric<MatcherLHS, MatchersRHS...>>::type
- operator || (MatcherLHS const& lhs, MatchAnyOfGeneric<MatchersRHS...> && rhs) {
- return MatchAnyOfGeneric<MatcherLHS, MatchersRHS...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
- }
-
- template<typename MatcherT>
- MatcherT const& operator ! (MatchNotOfGeneric<MatcherT> 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:<line number>: passed: a == t for: 3 == 3
Compilation.tests.cpp:<line number>: passed: throws_int(true)
Compilation.tests.cpp:<line number>: passed: throws_int(true), int
Compilation.tests.cpp:<line number>: passed: throws_int(false)
-Compilation.tests.cpp:<line number>: passed: "aaa", Catch::EndsWith("aaa") for: "aaa" ends with: "aaa"
+Compilation.tests.cpp:<line number>: passed: "aaa", Catch::Matchers::EndsWith("aaa") for: "aaa" ends with: "aaa"
Compilation.tests.cpp:<line number>: passed: templated_tests<int>(3) for: true
Misc.tests.cpp:<line number>: failed: f() == 0 for: 1 == 0
Misc.tests.cpp:<line number>: passed: errno == 1 for: 1 == 1
@@ -263,28 +263,28 @@ ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
-Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Detail::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
Matchers.tests.cpp:<line number>: 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:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Detail::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
Matchers.tests.cpp:<line number>: 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:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()