diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index a959095e..a2adf61f 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -32,6 +32,23 @@ namespace Matchers { }; namespace Generic { + template + struct Not : public MatcherImpl, ExpressionT> + { + Not( Matcher const& matcher ) : m_matcher(matcher.clone()) {} + Not( Not const& other ) : m_matcher( other.m_matcher ) {} + + virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE + { + return !m_matcher->match( expr ); + } + + virtual std::string toString() const CATCH_OVERRIDE { + return "not " + m_matcher->toString(); + } + + Ptr< Matcher > m_matcher; + }; template class AllOf : public MatcherImpl, ExpressionT> { @@ -204,6 +221,11 @@ namespace Matchers { // The following functions create the actual matcher objects. // This allows the types to be inferred + template + inline Impl::Generic::Not Not( Impl::Matcher const& m ) { + return Impl::Generic::Not( m ); + } + template inline Impl::Generic::AllOf AllOf( Impl::Matcher const& m1, Impl::Matcher const& m2 ) {