mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Merge pull request #43 from mat007/fix-function-param-forward
Fixed parameter forwarding bug in mock functions
This commit is contained in:
commit
d7b1ad0800
4 changed files with 26 additions and 13 deletions
|
|
@ -69,7 +69,7 @@ script:
|
|||
- cd $PROJECT_DIR/build
|
||||
- export BOOST_ROOT=$BOOST
|
||||
# `--coverage` flags required to generate coverage info for Coveralls
|
||||
- ./build.sh --toolset=$CC "cxxflags=-std=$CXX_STANDARD -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations --coverage" "--coverage"
|
||||
- ./build.sh --toolset=$CC "cxxflags=-std=$CXX_STANDARD -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations --coverage" "linkflags=--coverage"
|
||||
|
||||
after_success:
|
||||
- COVERALS_DIR=$PROJECT_DIR/coverals
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace detail
|
|||
virtual void serialize( std::ostream& s ) const
|
||||
{
|
||||
s << "" BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||
MOCK_EXPECTATION_SERIALIZE_ANY, _ );
|
||||
MOCK_EXPECTATION_SERIALIZE_ANY, _);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -84,12 +84,12 @@ namespace detail
|
|||
virtual void serialize( std::ostream& s ) const
|
||||
{
|
||||
s << BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||
MOCK_EXPECTATION_SERIALIZE, _ );
|
||||
MOCK_EXPECTATION_SERIALIZE, _);
|
||||
}
|
||||
|
||||
private:
|
||||
BOOST_PP_REPEAT(
|
||||
MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _ )
|
||||
MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _)
|
||||
};
|
||||
|
||||
template< typename F, typename Signature > class multi_matcher;
|
||||
|
|
|
|||
|
|
@ -72,16 +72,22 @@
|
|||
return t##_mock_; \
|
||||
}
|
||||
|
||||
#define MOCK_PARAM(z, n, d) \
|
||||
#define MOCK_PARAM(S, tpn) \
|
||||
tpn mock::detail::parameter< MOCK_FUNCTION_TYPE((S), tpn)
|
||||
#define MOCK_DECL_PARAM(z, n, d) \
|
||||
BOOST_PP_COMMA_IF(n) d, n >::type p##n
|
||||
#define MOCK_PARAMS(n, S, tpn) \
|
||||
BOOST_PP_REPEAT(n, MOCK_PARAM, \
|
||||
tpn mock::detail::parameter< MOCK_FUNCTION_TYPE((S), tpn))
|
||||
#define MOCK_DECL_PARAMS(n, S, tpn) \
|
||||
BOOST_PP_REPEAT(n, MOCK_DECL_PARAM, MOCK_PARAM(S, tpn))
|
||||
#define MOCK_DECL(M, n, S, c, tpn) \
|
||||
tpn boost::function_types::result_type< \
|
||||
MOCK_FUNCTION_TYPE((S), tpn) >::type M( \
|
||||
MOCK_PARAMS(n, S, tpn) ) c
|
||||
MOCK_DECL_PARAMS(n, S, tpn) ) c
|
||||
|
||||
#define MOCK_FORWARD_PARAM(z, n, d) \
|
||||
BOOST_PP_COMMA_IF(n) d, n >::type >( p##n )
|
||||
#define MOCK_FORWARD_PARAMS(n, S, tpn) \
|
||||
BOOST_PP_REPEAT(n, MOCK_FORWARD_PARAM, \
|
||||
boost::forward< MOCK_PARAM(S, tpn))
|
||||
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
||||
MOCK_DECL(M, n, S, c, tpn) \
|
||||
{ \
|
||||
|
|
@ -89,7 +95,7 @@
|
|||
boost::function_types::function_arity< \
|
||||
MOCK_FUNCTION_TYPE((S), tpn) >::value ); \
|
||||
return MOCK_ANONYMOUS_HELPER(t)( \
|
||||
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||
MOCK_FORWARD_PARAMS(n, S, tpn) ); \
|
||||
}
|
||||
|
||||
#define MOCK_METHOD_EXT(M, n, S, t) \
|
||||
|
|
@ -146,9 +152,9 @@
|
|||
}
|
||||
|
||||
#define MOCK_CONSTRUCTOR_AUX(T, n, A, t, tpn) \
|
||||
T( MOCK_PARAMS(n, void A, tpn) ) \
|
||||
T( MOCK_DECL_PARAMS(n, void A, tpn) ) \
|
||||
{ \
|
||||
MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||
MOCK_HELPER(t)( MOCK_FORWARD_PARAMS(n, void A, tpn) ); \
|
||||
} \
|
||||
MOCK_FUNCTION_HELPER(void A, t, static, tpn)
|
||||
|
||||
|
|
@ -168,7 +174,7 @@
|
|||
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
||||
boost::function_types::function_arity< \
|
||||
MOCK_FUNCTION_TYPE((S), tpn) >::value ); \
|
||||
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||
return MOCK_HELPER(t)( MOCK_FORWARD_PARAMS(n, S, tpn) ); \
|
||||
}
|
||||
|
||||
#ifdef MOCK_VARIADIC_MACROS
|
||||
|
|
|
|||
|
|
@ -769,4 +769,11 @@ BOOST_FIXTURE_TEST_CASE( std_unique_ptr_argument_is_supported_in_retrieve_constr
|
|||
}
|
||||
}
|
||||
|
||||
struct my_unique_ptr_class
|
||||
{
|
||||
MOCK_CONSTRUCTOR( my_unique_ptr_class, 1, ( std::unique_ptr< int > ), constructor )
|
||||
MOCK_METHOD_EXT( m, 1, void( std::unique_ptr< int > ), m )
|
||||
MOCK_STATIC_METHOD( ms, 1, void( std::unique_ptr< int > ), ms )
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue