diff --git a/build/vc80/turtle.vcproj b/build/vc80/turtle.vcproj
index b44e6e4..25b6967 100644
--- a/build/vc80/turtle.vcproj
+++ b/build/vc80/turtle.vcproj
@@ -169,7 +169,7 @@
>
+
+
diff --git a/build/vc80/turtle_test.vcproj b/build/vc80/turtle_test.vcproj
index 27fe1ff..e547f4a 100644
--- a/build/vc80/turtle_test.vcproj
+++ b/build/vc80/turtle_test.vcproj
@@ -191,7 +191,7 @@
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hpp;hxx;hm;inl;inc;xsd"
>
#include
diff --git a/src/libraries/turtle/constraint.hpp b/src/libraries/turtle/constraints.hpp
similarity index 68%
rename from src/libraries/turtle/constraint.hpp
rename to src/libraries/turtle/constraints.hpp
index 24b2581..0d322af 100644
--- a/src/libraries/turtle/constraint.hpp
+++ b/src/libraries/turtle/constraints.hpp
@@ -6,38 +6,14 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MOCK_CONSTRAINT_HPP_INCLUDED
-#define MOCK_CONSTRAINT_HPP_INCLUDED
+#ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
+#define MOCK_CONSTRAINTS_HPP_INCLUDED
-#include "placeholder.hpp"
#include "functional.hpp"
-#include "format.hpp"
-#include
+#include "operators.hpp"
namespace mock
{
- template< typename Functor, typename Description >
- const detail::placeholder< Functor > constraint( const Functor& f,
- const Description& desc )
- {
- std::stringstream s;
- s << std::boolalpha << desc;
- return detail::placeholder< Functor >( f, s.str() );
- }
- template< typename Functor >
- const detail::placeholder< Functor > constraint( const Functor& f )
- {
- return detail::placeholder< Functor >( f, "?" );
- }
- template< typename Functor, typename T >
- const detail::placeholder< Functor > constraint( const Functor& f,
- const std::string& name,
- const T& t )
- {
- return detail::placeholder< Functor >( f,
- name + "( " + format( t ) + " )" );
- }
-
namespace detail
{
template<>
@@ -135,4 +111,4 @@ namespace detail
}
}
-#endif // #ifndef MOCK_CONSTRAINT_HPP_INCLUDED
+#endif // #ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
diff --git a/src/libraries/turtle/expectation.hpp b/src/libraries/turtle/expectation.hpp
index df2d24b..fff3818 100644
--- a/src/libraries/turtle/expectation.hpp
+++ b/src/libraries/turtle/expectation.hpp
@@ -14,7 +14,7 @@
#include "action.hpp"
#include "sequence.hpp"
#include "check.hpp"
-#include "constraint.hpp"
+#include "constraints.hpp"
#include
#include
#include
diff --git a/src/libraries/turtle/operators.hpp b/src/libraries/turtle/operators.hpp
new file mode 100644
index 0000000..8a1f2e9
--- /dev/null
+++ b/src/libraries/turtle/operators.hpp
@@ -0,0 +1,100 @@
+//
+// Copyright Mathieu Champlon 2010
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef MOCK_OPERATORS_HPP_INCLUDED
+#define MOCK_OPERATORS_HPP_INCLUDED
+
+#include "placeholder.hpp"
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Functor1, typename Functor2 >
+ class and_
+ {
+ public:
+ and_( const Functor1& f1, const Functor2& f2 )
+ : f1_( f1 )
+ , f2_( f2 )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return f1_( actual ) && f2_( actual );
+ }
+ private:
+ Functor1 f1_;
+ Functor2 f2_;
+ };
+
+ template< typename Functor1, typename Functor2 >
+ class or_
+ {
+ public:
+ or_( const Functor1& f1, const Functor2& f2 )
+ : f1_( f1 )
+ , f2_( f2 )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return f1_( actual ) || f2_( actual );
+ }
+ private:
+ Functor1 f1_;
+ Functor2 f2_;
+ };
+
+ template< typename Functor >
+ class not_
+ {
+ public:
+ explicit not_( const Functor& f )
+ : f_( f )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return ! f_( actual );
+ }
+ private:
+ Functor f_;
+ };
+
+ template< typename Functor1, typename Functor2 >
+ const placeholder< or_< Functor1, Functor2 > >
+ operator||( const placeholder< Functor1 >& lhs,
+ const placeholder< Functor2 >& rhs )
+ {
+ return constraint(
+ or_< Functor1, Functor2 >( lhs.f_, rhs.f_ ),
+ "(" + lhs.desc_ + " || " + rhs.desc_ + ")" );
+ }
+
+ template< typename Functor1, typename Functor2 >
+ const placeholder< and_< Functor1, Functor2 > >
+ operator&&( const placeholder< Functor1 >& lhs,
+ const placeholder< Functor2 >& rhs )
+ {
+ return constraint(
+ and_< Functor1, Functor2 >( lhs.f_, rhs.f_ ),
+ "(" + lhs.desc_ + " && " + rhs.desc_ + ")" );
+ }
+
+ template< typename Functor >
+ const placeholder< not_< Functor > >
+ operator!( const placeholder< Functor >& ph )
+ {
+ return constraint(
+ not_< Functor >( ph.f_ ), "! " + ph.desc_ );
+ }
+}
+}
+
+#endif // #ifndef MOCK_OPERATORS_HPP_INCLUDED
diff --git a/src/libraries/turtle/placeholder.hpp b/src/libraries/turtle/placeholder.hpp
index 0470d04..13c41e1 100644
--- a/src/libraries/turtle/placeholder.hpp
+++ b/src/libraries/turtle/placeholder.hpp
@@ -9,7 +9,7 @@
#ifndef MOCK_PLACEHOLDER_HPP_INCLUDED
#define MOCK_PLACEHOLDER_HPP_INCLUDED
-#include
+#include "format.hpp"
namespace mock
{
@@ -25,87 +25,29 @@ namespace detail
Functor f_;
std::string desc_;
};
-
- template< typename Functor1, typename Functor2 >
- class and_
- {
- public:
- and_( const Functor1& f1, const Functor2& f2 )
- : f1_( f1 )
- , f2_( f2 )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return f1_( actual ) && f2_( actual );
- }
- private:
- Functor1 f1_;
- Functor2 f2_;
- };
-
- template< typename Functor1, typename Functor2 >
- class or_
- {
- public:
- or_( const Functor1& f1, const Functor2& f2 )
- : f1_( f1 )
- , f2_( f2 )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return f1_( actual ) || f2_( actual );
- }
- private:
- Functor1 f1_;
- Functor2 f2_;
- };
-
- template< typename Functor >
- class not_
- {
- public:
- explicit not_( const Functor& f )
- : f_( f )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return ! f_( actual );
- }
- private:
- Functor f_;
- };
-
- template< typename F1, typename F2 >
- const placeholder< or_< F1, F2 > >
- operator||( const placeholder< F1 >& lhs,
- const placeholder< F2 >& rhs )
- {
- return placeholder< or_< F1, F2 > >(
- or_< F1, F2 >( lhs.f_, rhs.f_ ),
- "(" + lhs.desc_ + " || " + rhs.desc_ + ")" );
- }
-
- template< typename F1, typename F2 >
- const placeholder< and_< F1, F2 > >
- operator&&( const placeholder< F1 >& lhs,
- const placeholder< F2 >& rhs )
- {
- return placeholder< and_< F1, F2 > >(
- and_< F1, F2 >( lhs.f_, rhs.f_ ),
- "(" + lhs.desc_ + " && " + rhs.desc_ + ")" );
- }
-
- template< typename F >
- const placeholder< not_< F > >
- operator!( const placeholder< F >& ph )
- {
- return placeholder< not_< F > >(
- not_< F >( ph.f_ ), "! " + ph.desc_ );
- }
}
+
+ template< typename Functor, typename Description >
+ const detail::placeholder< Functor > constraint( const Functor& f,
+ const Description& desc )
+ {
+ std::stringstream s;
+ s << std::boolalpha << desc;
+ return detail::placeholder< Functor >( f, s.str() );
+ }
+ template< typename Functor >
+ const detail::placeholder< Functor > constraint( const Functor& f )
+ {
+ return detail::placeholder< Functor >( f, "?" );
+ }
+ template< typename Functor, typename T >
+ const detail::placeholder< Functor > constraint( const Functor& f,
+ const std::string& name,
+ const T& t )
+ {
+ return detail::placeholder< Functor >( f,
+ name + "( " + format( t ) + " )" );
+ }
}
#endif // #ifndef MOCK_PLACEHOLDER_HPP_INCLUDED
diff --git a/src/tests/turtle_test/constraint_test.cpp b/src/tests/turtle_test/constraints_test.cpp
similarity index 94%
rename from src/tests/turtle_test/constraint_test.cpp
rename to src/tests/turtle_test/constraints_test.cpp
index df577a4..2ee756d 100644
--- a/src/tests/turtle_test/constraint_test.cpp
+++ b/src/tests/turtle_test/constraints_test.cpp
@@ -6,7 +6,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
-#include
+#include
#include
#define BOOST_LIB_NAME boost_unit_test_framework