Added a much better workaround to the comma-in-macro problem

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@419 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-03-05 22:50:45 +00:00
parent e725d1c006
commit 3fa0d17785
2 changed files with 22 additions and 2 deletions

View file

@ -49,7 +49,10 @@ namespace detail
{}; {};
template< typename T > template< typename T >
struct base struct base;
template< typename T >
struct base< void( T ) > : T
{ {
typedef T base_type; typedef T base_type;
}; };
@ -78,7 +81,7 @@ namespace detail
} }
#define MOCK_BASE_CLASS(T, I) \ #define MOCK_BASE_CLASS(T, I) \
struct T : I, mock::object, mock::detail::base< I > struct T : mock::detail::base< void( I ) >, mock::object
#define MOCK_CLASS(T) \ #define MOCK_CLASS(T) \
struct T : mock::object struct T : mock::object
#define MOCK_FUNCTOR(f, S) \ #define MOCK_FUNCTOR(f, S) \

View file

@ -319,3 +319,20 @@ BOOST_AUTO_TEST_CASE( mock_static_function_is_named )
{ {
BOOST_CHECK_EQUAL( "static_function_class::mock_static_function", to_string( MOCK_MOCKER( static_function_class::mock_static_function ) ) ); BOOST_CHECK_EQUAL( "static_function_class::mock_static_function", to_string( MOCK_MOCKER( static_function_class::mock_static_function ) ) );
} }
namespace
{
template< typename T1, typename T2 >
struct base_template_class
{};
MOCK_BASE_CLASS( mock_instanciated_template_class, (base_template_class< int, int >) )
{};
template< typename T >
MOCK_BASE_CLASS( mock_template_class, (base_template_class< T, T >) )
{};
}
BOOST_AUTO_TEST_CASE( mock_template_class_can_be_instanciated )
{
mock_template_class< int > c;
}