1 //          Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef SNOWHOUSE_FULFILLSCONSTRAINT_H
7 #define SNOWHOUSE_FULFILLSCONSTRAINT_H
8 
9 #include "expressions/expression.h"
10 
11 namespace snowhouse
12 {
13   template<typename MatcherType>
14   struct FulfillsConstraint : Expression<FulfillsConstraint<MatcherType> >
15   {
FulfillsConstraintFulfillsConstraint16     FulfillsConstraint(const MatcherType& matcher)
17         : m_matcher(matcher)
18     {
19     }
20 
21     template<typename ActualType>
operatorFulfillsConstraint22     bool operator()(const ActualType& actual) const
23     {
24       return m_matcher.Matches(actual);
25     }
26 
27     MatcherType m_matcher;
28   };
29 
30   template<typename MatcherType>
Fulfills(const MatcherType & matcher)31   inline FulfillsConstraint<MatcherType> Fulfills(const MatcherType& matcher)
32   {
33     return FulfillsConstraint<MatcherType>(matcher);
34   }
35 
36   template<typename MatcherType>
37   struct Stringizer<FulfillsConstraint<MatcherType> >
38   {
39     static std::string ToString(const FulfillsConstraint<MatcherType>& constraint)
40     {
41       std::ostringstream builder;
42       builder << snowhouse::Stringize(constraint.m_matcher);
43 
44       return builder.str();
45     }
46   };
47 }
48 
49 #endif
50