diff --git a/build/vc80/turtle_test.vcproj b/build/vc80/turtle_test.vcproj
index e547f4a..492812c 100644
--- a/build/vc80/turtle_test.vcproj
+++ b/build/vc80/turtle_test.vcproj
@@ -218,6 +218,10 @@
RelativePath="..\..\src\tests\turtle_test\is_functor_test.cpp"
>
+
+
diff --git a/src/libraries/turtle/action.hpp b/src/libraries/turtle/action.hpp
index e35698f..988b280 100644
--- a/src/libraries/turtle/action.hpp
+++ b/src/libraries/turtle/action.hpp
@@ -10,6 +10,9 @@
#define MOCK_ACTION_HPP_INCLUDED
#include "config.hpp"
+#include
+#include
+#include
#include
#include
#include
@@ -41,7 +44,7 @@ namespace detail
template< typename Exception >
void throws( Exception e )
{
- f_ = boost::bind( &throw_exception< Exception >, e );
+ f_ = boost::phoenix::bind( &throw_exception< Exception >, e );
}
const functor_type& functor() const
@@ -52,15 +55,17 @@ namespace detail
private:
void set( Result r )
{
- f_ = boost::bind( &return_value, r );
+ f_ = (boost::phoenix::bind( ¬hing ), boost::bind( &identity, r ));
}
template< typename Y >
void set( const boost::reference_wrapper< Y >& r )
{
- f_ = boost::bind( &return_value, r );
+ f_ = boost::phoenix::val( r );
}
- static Result return_value( Result r )
+ static void nothing()
+ {}
+ static Result identity( Result r )
{
return r;
}
@@ -83,12 +88,12 @@ namespace detail
public:
void returns( Result* r )
{
- f_ = boost::bind( &return_value, r );
+ f_ = boost::phoenix::val( r );
}
template< typename Y >
void returns( const boost::reference_wrapper< Y >& r )
{
- f_ = boost::bind( &return_value, r );
+ f_ = boost::phoenix::val( r );
}
void calls( const functor_type& f )
@@ -101,7 +106,7 @@ namespace detail
template< typename Exception >
void throws( Exception e )
{
- f_ = boost::bind( &throw_exception< Exception >, e );
+ f_ = boost::phoenix::bind( &throw_exception< Exception >, e );
}
const functor_type& functor() const
@@ -110,11 +115,6 @@ namespace detail
}
private:
- static Result* return_value( Result* r )
- {
- return r;
- }
-
template< typename Exception >
static Result* throw_exception( const Exception& e )
{
@@ -132,7 +132,7 @@ namespace detail
public:
action()
- : f_( boost::bind( ¬hing ) )
+ : f_( boost::phoenix::bind( ¬hing ) )
{}
void calls( const functor_type& f )
@@ -145,7 +145,7 @@ namespace detail
template< typename Exception >
void throws( Exception e )
{
- f_ = boost::bind( &throw_exception< Exception >, e );
+ f_ = boost::phoenix::bind( &throw_exception< Exception >, e );
}
const functor_type& functor() const
@@ -179,7 +179,7 @@ namespace detail
{}
action( const action& rhs )
: r_( const_cast< action& >( rhs ).r_.release() )
- , f_( r_.get() ? boost::bind( &return_value, boost::ref( r_ ) ) : rhs.f_ )
+ , f_( r_.get() ? boost::phoenix::val( boost::ref( r_ ) ) : rhs.f_ )
{}
template< typename Value >
@@ -198,7 +198,7 @@ namespace detail
template< typename Exception >
void throws( Exception e )
{
- f_ = boost::bind( &throw_exception< Exception >, e );
+ f_ = boost::phoenix::bind( &throw_exception< Exception >, e );
r_.reset();
}
@@ -212,24 +212,19 @@ namespace detail
void set( std::auto_ptr< Y > r )
{
r_ = r;
- f_ = boost::bind( &return_value, boost::ref( r_ ) );
+ f_ = boost::phoenix::val( boost::ref( r_ ) );
}
template< typename Y >
void set( const boost::reference_wrapper< Y >& r )
{
- f_ = boost::bind( &return_value, r );
+ f_ = boost::phoenix::val( r );
r_.reset();
}
template< typename Y >
void set( Y* r )
{
r_.reset( r );
- f_ = boost::bind( &return_value, boost::ref( r_ ) );
- }
-
- static std::auto_ptr< Result > return_value( std::auto_ptr< Result > r )
- {
- return r;
+ f_ = boost::phoenix::val( boost::ref( r_ ) );
}
template< typename Exception >
diff --git a/src/libraries/turtle/config.hpp b/src/libraries/turtle/config.hpp
index a671fa2..beae072 100644
--- a/src/libraries/turtle/config.hpp
+++ b/src/libraries/turtle/config.hpp
@@ -9,17 +9,24 @@
#ifndef MOCK_CONFIG_HPP_INCLUDED
#define MOCK_CONFIG_HPP_INCLUDED
-#include
-#include
#include
-#include
#ifndef MOCK_MAX_ARGS
# define MOCK_MAX_ARGS 10
#endif
#define MOCK_NUM_ARGS BOOST_PP_INC(MOCK_MAX_ARGS)
-BOOST_PP_ASSERT( BOOST_PP_LESS_EQUAL(MOCK_MAX_ARGS, BOOST_FUNCTION_MAX_ARGS) )
+#ifndef PHOENIX_LIMIT
+# define PHOENIX_LIMIT MOCK_MAX_ARGS
+#elif (PHOENIX_LIMIT < MOCK_MAX_ARGS)
+# error "PHOENIX_LIMIT is set too low"
+#endif
+
+#ifndef BOOST_FUNCTION_MAX_ARGS
+# define BOOST_FUNCTION_MAX_ARGS MOCK_MAX_ARGS
+#elif (BOOST_FUNCTION_MAX_ARGS < MOCK_MAX_ARGS)
+# error "BOOST_FUNCTION_MAX_ARGS is set too low"
+#endif
#ifdef BOOST_TEST_DECL
# define MOCK_USE_BOOST_TEST
diff --git a/src/libraries/turtle/mock.hpp b/src/libraries/turtle/mock.hpp
index 1efce95..5f4dee2 100644
--- a/src/libraries/turtle/mock.hpp
+++ b/src/libraries/turtle/mock.hpp
@@ -9,6 +9,7 @@
#ifndef MOCK_MOCK_HPP_INCLUDED
#define MOCK_MOCK_HPP_INCLUDED
+#include "config.hpp"
#include "error.hpp"
#include "object.hpp"
#include "function.hpp"
diff --git a/src/tests/turtle_test/max_args_test.cpp b/src/tests/turtle_test/max_args_test.cpp
new file mode 100644
index 0000000..c101395
--- /dev/null
+++ b/src/tests/turtle_test/max_args_test.cpp
@@ -0,0 +1,36 @@
+
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+//
+
+#include "silent_error.hpp"
+
+#define MOCK_MAX_ARGS 20
+#define MOCK_ERROR_POLICY silent_error
+#include
+#include
+
+#include
+#define BOOST_LIB_NAME boost_unit_test_framework
+#include
+
+#define TEXT(z, n, text) text
+
+namespace
+{
+ struct my_custom_mock
+ {
+ MOCK_METHOD_EXT( my_method_with_max_number_of_args, MOCK_MAX_ARGS, void( BOOST_PP_ENUM(MOCK_MAX_ARGS, TEXT, int) ), my_method_with_max_number_of_args )
+ };
+}
+
+BOOST_AUTO_TEST_CASE( call_mock_method_with_max_number_of_args )
+{
+ my_custom_mock m;
+ MOCK_EXPECT( m, my_method_with_max_number_of_args ).once().with( BOOST_PP_ENUM(MOCK_MAX_ARGS, TEXT, 0) );
+ m.my_method_with_max_number_of_args( BOOST_PP_ENUM(MOCK_MAX_ARGS, TEXT, 0) );
+}