diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj index 944ccf1..f87da0f 100644 --- a/build/vc100/turtle.vcxproj +++ b/build/vc100/turtle.vcxproj @@ -41,7 +41,6 @@ - diff --git a/build/vc100/turtle.vcxproj.filters b/build/vc100/turtle.vcxproj.filters index e4ecc2e..cefd6a2 100644 --- a/build/vc100/turtle.vcxproj.filters +++ b/build/vc100/turtle.vcxproj.filters @@ -97,9 +97,6 @@ Source Files\detail - - Source Files\detail - Source Files\detail diff --git a/test/test_constraints.cpp b/test/test_constraints.cpp index f4aba81..ff2338b 100644 --- a/test/test_constraints.cpp +++ b/test/test_constraints.cpp @@ -7,7 +7,6 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include BOOST_AUTO_TEST_CASE( all_comparison_constraints_can_be_instanciated ) diff --git a/turtle/constraint.hpp b/turtle/constraint.hpp index a5326e6..01648db 100644 --- a/turtle/constraint.hpp +++ b/turtle/constraint.hpp @@ -22,6 +22,98 @@ namespace mock {} Constraint f_; }; + +namespace detail +{ + template< typename Constraint1, typename Constraint2 > + class and_ + { + public: + and_( const Constraint1& c1, const Constraint2& c2 ) + : c1_( c1 ) + , c2_( c2 ) + {} + template< typename Actual > + bool operator()( const Actual& actual ) const + { + return c1_( actual ) && c2_( actual ); + } + friend std::ostream& operator<<( std::ostream& s, const and_& a ) + { + return s << "( " << mock::format( a.c1_ ) + << " && " << mock::format( a.c2_ ) << " )"; + } + private: + Constraint1 c1_; + Constraint2 c2_; + }; + + template< typename Constraint1, typename Constraint2 > + class or_ + { + public: + or_( const Constraint1& c1, const Constraint2& c2 ) + : c1_( c1 ) + , c2_( c2 ) + {} + template< typename Actual > + bool operator()( const Actual& actual ) const + { + return c1_( actual ) || c2_( actual ); + } + friend std::ostream& operator<<( std::ostream& s, const or_& o ) + { + return s << "( " << mock::format( o.c1_ ) + << " || " << mock::format( o.c2_ )<< " )"; + } + private: + Constraint1 c1_; + Constraint2 c2_; + }; + + template< typename Constraint > + class not_ + { + public: + explicit not_( const Constraint& f ) + : f_( f ) + {} + template< typename Actual > + bool operator()( const Actual& actual ) const + { + return ! f_( actual ); + } + friend std::ostream& operator<<( std::ostream& s, const not_& n ) + { + return s << "! " << mock::format( n.f_ ); + } + private: + Constraint f_; + }; +} + + template< typename Constraint1, typename Constraint2 > + const constraint< detail::or_< Constraint1, Constraint2 > > + operator||( const constraint< Constraint1 >& lhs, + const constraint< Constraint2 >& rhs ) + { + return detail::or_< Constraint1, Constraint2 >( lhs.f_, rhs.f_ ); + } + + template< typename Constraint1, typename Constraint2 > + const constraint< detail::and_< Constraint1, Constraint2 > > + operator&&( const constraint< Constraint1 >& lhs, + const constraint< Constraint2 >& rhs ) + { + return detail::and_< Constraint1, Constraint2 >( lhs.f_, rhs.f_ ); + } + + template< typename Constraint > + const constraint< detail::not_< Constraint > > + operator!( const constraint< Constraint >& c ) + { + return detail::not_< Constraint >( c.f_ ); + } } // mock #define MOCK_UNARY_CONSTRAINT(N,Expr) \ diff --git a/turtle/detail/check.hpp b/turtle/detail/check.hpp index e387375..3af3f10 100644 --- a/turtle/detail/check.hpp +++ b/turtle/detail/check.hpp @@ -9,7 +9,6 @@ #ifndef MOCK_CHECK_HPP_INCLUDED #define MOCK_CHECK_HPP_INCLUDED -#include "operators.hpp" #include "is_functor.hpp" #include "../log.hpp" #include