diff options
| author | Phil Nash | 2015-08-24 06:22:03 +0100 |
|---|---|---|
| committer | Phil Nash | 2015-08-24 06:22:03 +0100 |
| commit | 7fd7c5b8c87097d2bc6c3f09f7c5fd5daa04dbfc (patch) | |
| tree | 8028e9b659581df6c3eff8dfeb721f6e624a4367 /include | |
| parent | 40d0d2f65647bd429604cd8856e1eadb47843eb5 (diff) | |
| parent | 312b94e532100fbda8540bf4f15fb1cdc2b8cd71 (diff) | |
| download | catch3-7fd7c5b8c87097d2bc6c3f09f7c5fd5daa04dbfc.tar.gz | |
Merge branch 'matcher-not' into develop
* matcher-not:
Add matcher: Not()
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_matchers.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
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<typename ExpressionT> + struct Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> + { + Not( Matcher<ExpressionT> 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<ExpressionT> > m_matcher; + }; template<typename ExpressionT> class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> { @@ -205,6 +222,11 @@ namespace Matchers { // The following functions create the actual matcher objects. // This allows the types to be inferred template<typename ExpressionT> + inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<ExpressionT> const& m ) { + return Impl::Generic::Not<ExpressionT>( m ); + } + + template<typename ExpressionT> inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1, Impl::Matcher<ExpressionT> const& m2 ) { return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ); |