mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added MOCK_NO_VARIADIC_MACROS to deactivate variadic macros support
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@668 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
8d08012cdf
commit
f97fb87f81
9 changed files with 58 additions and 36 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
Not yet released
|
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
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ rule run-test ( name )
|
||||||
run $(name).cpp /boost//unit_test_framework : : : : $(name) ;
|
run $(name).cpp /boost//unit_test_framework : : : : $(name) ;
|
||||||
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_MAX_ARGS=21 : $(name)_max_args ;
|
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_MAX_ARGS=21 : $(name)_max_args ;
|
||||||
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
|
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
|
||||||
|
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_NO_DECLTYPE : $(name)_no_decltype ;
|
||||||
|
run $(name).cpp /boost//unit_test_framework : : : <define>MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ;
|
||||||
}
|
}
|
||||||
|
|
||||||
alias mock_tests :
|
alias mock_tests :
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,12 @@
|
||||||
<build-turtle-test name="turtle_use_conversions">
|
<build-turtle-test name="turtle_use_conversions">
|
||||||
<defineset define="MOCK_USE_CONVERSIONS"/>
|
<defineset define="MOCK_USE_CONVERSIONS"/>
|
||||||
</build-turtle-test>
|
</build-turtle-test>
|
||||||
|
<build-turtle-test name="turtle_no_decltype">
|
||||||
|
<defineset define="MOCK_NO_DECLTYPE"/>
|
||||||
|
</build-turtle-test>
|
||||||
|
<build-turtle-test name="turtle_no_variadic_macros">
|
||||||
|
<defineset define="MOCK_NO_VARIADIC_MACROS"/>
|
||||||
|
</build-turtle-test>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="analyse" description="run errors analyser">
|
<target name="analyse" description="run errors analyser">
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct declared_but_not_defined;
|
struct declared_but_not_defined;
|
||||||
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< declared_but_not_defined, int > ));
|
BOOST_MPL_ASSERT_NOT((
|
||||||
|
mock::detail::is_functor< declared_but_not_defined, int > ));
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void is_functor( T )
|
void is_functor( T )
|
||||||
|
|
@ -142,7 +143,11 @@ BOOST_AUTO_TEST_CASE( class_with_sig_is_functor )
|
||||||
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
|
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
|
||||||
{
|
{
|
||||||
is_not_functor( []() {} );
|
is_not_functor( []() {} );
|
||||||
|
#ifdef MOCK_DECLTYPE
|
||||||
is_functor( []( int ) {} );
|
is_functor( []( int ) {} );
|
||||||
|
#else
|
||||||
|
is_not_functor( []( int ) {} );
|
||||||
|
#endif
|
||||||
is_not_functor( []( const std::string&, int ) {} );
|
is_not_functor( []( const std::string&, int ) {} );
|
||||||
is_not_functor( []( int, const std::string& ) {} );
|
is_not_functor( []( int, const std::string& ) {} );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <turtle/constraint.hpp>
|
#include <turtle/constraint.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
|
|
||||||
#ifndef BOOST_NO_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -25,4 +25,4 @@ BOOST_AUTO_TEST_CASE( mock_constraint_is_supported_by_compilers_with_variadic_ma
|
||||||
BOOST_CHECK( constraint_2( 0, 0 ).c_( 0 ) );
|
BOOST_CHECK( constraint_2( 0, 0 ).c_( 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BOOST_NO_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ namespace
|
||||||
MOCK_FUNCTION( fun0, 0, (std::map< int, int >()), fun0 )
|
MOCK_FUNCTION( fun0, 0, (std::map< int, int >()), fun0 )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -390,4 +390,4 @@ namespace
|
||||||
MOCK_FUNCTOR( f_variadic, std::map< int, int >() );
|
MOCK_FUNCTOR( f_variadic, std::map< int, int >() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //BOOST_NO_VARIADIC_MACROS
|
#endif //MOCK_VARIADIC_MACROS
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,15 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
|
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
|
||||||
# define MOCK_DECLTYPE
|
# ifndef MOCK_NO_DECLTYPE
|
||||||
|
# define MOCK_DECLTYPE
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS)
|
||||||
|
# ifndef MOCK_NO_VARIADIC_MACROS
|
||||||
|
# define MOCK_VARIADIC_MACROS
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MOCK_CONFIG_HPP_INCLUDED
|
#endif // MOCK_CONFIG_HPP_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ namespace detail
|
||||||
MOCK_NARY_CONSTRAINT, \
|
MOCK_NARY_CONSTRAINT, \
|
||||||
MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
|
MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
|
||||||
|
|
||||||
#ifndef BOOST_NO_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#if BOOST_MSVC
|
#if BOOST_MSVC
|
||||||
# define MOCK_VARIADIC_SIZE(...) \
|
# define MOCK_VARIADIC_SIZE(...) \
|
||||||
|
|
@ -242,6 +242,6 @@ namespace detail
|
||||||
MOCK_CONSTRAINT_AUX( \
|
MOCK_CONSTRAINT_AUX( \
|
||||||
Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
|
Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
|
||||||
|
|
||||||
#endif // BOOST_NO_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#endif // MOCK_CONSTRAINT_HPP_INCLUDED
|
#endif // MOCK_CONSTRAINT_HPP_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,7 @@
|
||||||
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
||||||
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE((S)) >::type
|
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE((S)) >::type
|
||||||
|
|
||||||
#ifdef BOOST_NO_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_BASE_CLASS(T, I) \
|
|
||||||
struct T : I, mock::object, mock::detail::base< I >
|
|
||||||
|
|
||||||
#define MOCK_FUNCTOR(f, S) \
|
|
||||||
mock::detail::functor< MOCK_FUNCTION_TYPE(S,) > f, f##_mock
|
|
||||||
#define MOCK_FUNCTOR_TPL(f, S) \
|
|
||||||
mock::detail::functor< \
|
|
||||||
MOCK_FUNCTION_TYPE(S, BOOST_DEDUCED_TYPENAME) > f, f##_mock
|
|
||||||
|
|
||||||
#else // BOOST_NO_VARIADIC_MACROS
|
|
||||||
|
|
||||||
#define MOCK_BASE_CLASS(T, ...) \
|
#define MOCK_BASE_CLASS(T, ...) \
|
||||||
struct T : __VA_ARGS__, mock::object, mock::detail::base< __VA_ARGS__ >
|
struct T : __VA_ARGS__, mock::object, mock::detail::base< __VA_ARGS__ >
|
||||||
|
|
@ -52,7 +41,18 @@
|
||||||
mock::detail::functor< \
|
mock::detail::functor< \
|
||||||
MOCK_FUNCTION_TYPE((__VA_ARGS__), BOOST_DEDUCED_TYPENAME) > f, f##_mock
|
MOCK_FUNCTION_TYPE((__VA_ARGS__), BOOST_DEDUCED_TYPENAME) > f, f##_mock
|
||||||
|
|
||||||
#endif // BOOST_NO_VARIADIC_MACROS
|
#else // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
|
#define MOCK_BASE_CLASS(T, I) \
|
||||||
|
struct T : I, mock::object, mock::detail::base< I >
|
||||||
|
|
||||||
|
#define MOCK_FUNCTOR(f, S) \
|
||||||
|
mock::detail::functor< MOCK_FUNCTION_TYPE(S,) > f, f##_mock
|
||||||
|
#define MOCK_FUNCTOR_TPL(f, S) \
|
||||||
|
mock::detail::functor< \
|
||||||
|
MOCK_FUNCTION_TYPE(S, BOOST_DEDUCED_TYPENAME) > f, f##_mock
|
||||||
|
|
||||||
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_HELPER(t) \
|
#define MOCK_HELPER(t) \
|
||||||
t##_mock( mock::detail::root, BOOST_PP_STRINGIZE(t) )
|
t##_mock( mock::detail::root, BOOST_PP_STRINGIZE(t) )
|
||||||
|
|
@ -171,20 +171,7 @@
|
||||||
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_NO_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_METHOD(M, n) \
|
|
||||||
MOCK_METHOD_EXT(M, n, MOCK_SIGNATURE(M), M)
|
|
||||||
|
|
||||||
#define MOCK_FUNCTION(F, n, S, t) \
|
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t,,)
|
|
||||||
|
|
||||||
#define MOCK_STATIC_METHOD(F, n, S, t) \
|
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t, static,)
|
|
||||||
#define MOCK_STATIC_METHOD_TPL(F, n, S, t) \
|
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t, static, BOOST_DEDUCED_TYPENAME)
|
|
||||||
|
|
||||||
#else // BOOST_NO_VARIADIC_MACROS
|
|
||||||
|
|
||||||
#define MOCK_VARIADIC_ELEM_0(e0, ...) e0
|
#define MOCK_VARIADIC_ELEM_0(e0, ...) e0
|
||||||
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
|
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
|
||||||
|
|
@ -233,7 +220,20 @@
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), \
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), \
|
||||||
static, BOOST_DEDUCED_TYPENAME)
|
static, BOOST_DEDUCED_TYPENAME)
|
||||||
|
|
||||||
#endif // BOOST_NO_VARIADIC_MACROS
|
#else // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
|
#define MOCK_METHOD(M, n) \
|
||||||
|
MOCK_METHOD_EXT(M, n, MOCK_SIGNATURE(M), M)
|
||||||
|
|
||||||
|
#define MOCK_FUNCTION(F, n, S, t) \
|
||||||
|
MOCK_FUNCTION_AUX(F, n, S, t,,)
|
||||||
|
|
||||||
|
#define MOCK_STATIC_METHOD(F, n, S, t) \
|
||||||
|
MOCK_FUNCTION_AUX(F, n, S, t, static,)
|
||||||
|
#define MOCK_STATIC_METHOD_TPL(F, n, S, t) \
|
||||||
|
MOCK_FUNCTION_AUX(F, n, S, t, static, BOOST_DEDUCED_TYPENAME)
|
||||||
|
|
||||||
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_EXPECT(t) MOCK_HELPER(t).expect( __FILE__, __LINE__ )
|
#define MOCK_EXPECT(t) MOCK_HELPER(t).expect( __FILE__, __LINE__ )
|
||||||
#define MOCK_RESET(t) MOCK_HELPER(t).reset( __FILE__, __LINE__ )
|
#define MOCK_RESET(t) MOCK_HELPER(t).reset( __FILE__, __LINE__ )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue