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_ISGREATERTHANCONSTRAINT_H
7 #define SNOWHOUSE_ISGREATERTHANCONSTRAINT_H
8 
9 #include "expressions/expression.h"
10 
11 namespace snowhouse
12 {
13   template<typename ExpectedType>
14   struct IsGreaterThanConstraint : Expression<IsGreaterThanConstraint<ExpectedType> >
15   {
IsGreaterThanConstraintIsGreaterThanConstraint16     IsGreaterThanConstraint(const ExpectedType& expected)
17         : m_expected(expected)
18     {
19     }
20 
21     template<typename ActualType>
operatorIsGreaterThanConstraint22     bool operator()(const ActualType& actual) const
23     {
24       return (actual > m_expected);
25     }
26 
27     ExpectedType m_expected;
28   };
29 
30   template<typename ExpectedType>
IsGreaterThan(const ExpectedType & expected)31   inline IsGreaterThanConstraint<ExpectedType> IsGreaterThan(const ExpectedType& expected)
32   {
33     return IsGreaterThanConstraint<ExpectedType>(expected);
34   }
35 
IsGreaterThan(const char * expected)36   inline IsGreaterThanConstraint<std::string> IsGreaterThan(const char* expected)
37   {
38     return IsGreaterThanConstraint<std::string>(expected);
39   }
40 
41   template<typename ExpectedType>
42   struct Stringizer<IsGreaterThanConstraint<ExpectedType> >
43   {
44     static std::string ToString(const IsGreaterThanConstraint<ExpectedType>& constraint)
45     {
46       std::ostringstream builder;
47       builder << "greater than " << snowhouse::Stringize(constraint.m_expected);
48 
49       return builder.str();
50     }
51   };
52 }
53 
54 #endif
55