mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added support for movable only types as parameters
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@676 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
8c26729399
commit
068f73b0bc
5 changed files with 35 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ Not yet released
|
||||||
|
|
||||||
* Reworked MOCK_CONSTRAINT to be able to provide names to parameters
|
* Reworked MOCK_CONSTRAINT to be able to provide names to parameters
|
||||||
* Added MOCK_NO_VARIADIC_MACROS to deactivate variadic macros support
|
* Added MOCK_NO_VARIADIC_MACROS to deactivate variadic macros support
|
||||||
|
* Added support for movable only types as parameters
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,19 @@ BOOST_FIXTURE_TEST_CASE( nullptr_can_be_used_in_place_of_null_pointers_in_constr
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MOCK_SMART_PTR
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE( unique_ptr_is_supported_as_parameter, error_fixture )
|
||||||
|
{
|
||||||
|
mock::detail::function< void( std::unique_ptr< int > ) > f;
|
||||||
|
f.expect();
|
||||||
|
std::unique_ptr< int > p( new int );
|
||||||
|
f( std::move( p ) );
|
||||||
|
CHECK_CALLS( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MOCK_SMART_PTR
|
||||||
|
|
||||||
// result handling
|
// result handling
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_missing_action, error_fixture )
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_missing_action, error_fixture )
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,10 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_SMART_PTR)
|
||||||
|
# ifndef MOCK_NO_SMART_PTR
|
||||||
|
# define MOCK_SMART_PTR
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // MOCK_CONFIG_HPP_INCLUDED
|
#endif // MOCK_CONFIG_HPP_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <boost/test/utils/lazy_ostream.hpp>
|
#include <boost/test/utils/lazy_ostream.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
#include <boost/call_traits.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@
|
||||||
|
|
||||||
#include "function_impl_template.hpp"
|
#include "function_impl_template.hpp"
|
||||||
|
|
||||||
|
#define MOCK_FUNCTION_CALL(z, n, d ) \
|
||||||
|
BOOST_PP_COMMA_IF(n) BOOST_DEDUCED_TYPENAME \
|
||||||
|
boost::call_traits< T##n >::param_type
|
||||||
|
|
||||||
|
#define MOCK_FUNCTION_PARAM(z, n, d) \
|
||||||
|
MOCK_FUNCTION_CALL(z, n, d) t##n
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
|
|
@ -29,7 +36,8 @@ namespace detail
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef function_impl<
|
typedef function_impl<
|
||||||
R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) > impl_type;
|
R ( BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_CALL, _) )
|
||||||
|
> impl_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
impl_type::expectation_type expectation_type;
|
impl_type::expectation_type expectation_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME impl_type::error_type error_type;
|
typedef BOOST_DEDUCED_TYPENAME impl_type::error_type error_type;
|
||||||
|
|
@ -68,7 +76,8 @@ namespace detail
|
||||||
return impl_->expect();
|
return impl_->expect();
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()( BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, t) ) const
|
R operator()(
|
||||||
|
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_PARAM, _) ) const
|
||||||
{
|
{
|
||||||
return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
||||||
}
|
}
|
||||||
|
|
@ -105,3 +114,6 @@ namespace detail
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
|
#undef MOCK_FUNCTION_CALL
|
||||||
|
#undef MOCK_FUNCTION_PARAM
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue