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

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorSimon Warta2015-08-12 11:05:16 +0200
committerSimon Warta2015-08-12 11:07:55 +0200
commit312b94e532100fbda8540bf4f15fb1cdc2b8cd71 (patch)
tree4e8c777d43b7872df032bd08980dd62cdd365eda /include/internal
parent19520157fb6905c8ba9cc1e0680c824b0b0c454c (diff)
downloadcatch3-312b94e532100fbda8540bf4f15fb1cdc2b8cd71.tar.gz
Add matcher: Not()
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_matchers.hpp22
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 );