mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Factorized MOCK_TYPE_NAME
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@725 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
30dadf0c61
commit
cbb4683dde
4 changed files with 8 additions and 6 deletions
|
|
@ -15,7 +15,7 @@ namespace
|
|||
template< typename T >
|
||||
std::string to_string( const T& )
|
||||
{
|
||||
return boost::lexical_cast< std::string >( mock::detail::type_name( BOOST_SP_TYPEID( T ) ) );
|
||||
return boost::lexical_cast< std::string >( MOCK_TYPE_NAME(T) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE( name_of_type_in_unnamed_inner_namespace_is_extracted )
|
|||
BOOST_AUTO_TEST_CASE( name_of_local_type_is_extracted )
|
||||
{
|
||||
struct my_local_type {};
|
||||
BOOST_CHECK_EQUAL( "my_local_type", boost::lexical_cast< std::string >( mock::detail::type_name( BOOST_SP_TYPEID( my_local_type ) ) ) );
|
||||
BOOST_CHECK_EQUAL( "my_local_type", boost::lexical_cast< std::string >( MOCK_TYPE_NAME(my_local_type) ) );
|
||||
}
|
||||
|
||||
namespace
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace
|
|||
{
|
||||
fixture()
|
||||
{
|
||||
mock::detail::configure( o, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( o ) ), "name" );
|
||||
mock::detail::configure( o, e, "instance", MOCK_TYPE_NAME(o), "name" );
|
||||
}
|
||||
object o;
|
||||
mock::detail::function< void() > e;
|
||||
|
|
@ -72,7 +72,7 @@ BOOST_FIXTURE_TEST_CASE( an_object_is_assignable_by_sharing_its_state, mock_erro
|
|||
mock::detail::function< void() > e;
|
||||
{
|
||||
object o2;
|
||||
mock::detail::configure( o2, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( o2 ) ), "name" );
|
||||
mock::detail::configure( o2, e, "instance", MOCK_TYPE_NAME(o2), "name" );
|
||||
e.expect().once();
|
||||
o1 = o2;
|
||||
CHECK_ERROR(
|
||||
|
|
@ -92,7 +92,7 @@ BOOST_FIXTURE_TEST_CASE( an_object_is_copiable_by_sharing_its_state, mock_error_
|
|||
std::auto_ptr< object > o2( new object );
|
||||
const object o1( *o2 );
|
||||
mock::detail::function< void() > e;
|
||||
mock::detail::configure( *o2, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( *o2 ) ), "name" );
|
||||
mock::detail::configure( *o2, e, "instance", MOCK_TYPE_NAME(*o2), "name" );
|
||||
e.expect().once();
|
||||
CHECK_ERROR(
|
||||
BOOST_CHECK( ! mock::verify( *o2 ) ),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#define MOCK_TYPE_NAME( T ) mock::detail::type_name( BOOST_SP_TYPEID(T) )
|
||||
|
||||
namespace mock
|
||||
{
|
||||
namespace detail
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
{ \
|
||||
mock::detail::configure( *this, t##_mock_, \
|
||||
instance.substr( 0, instance.rfind( BOOST_PP_STRINGIZE(t) ) ), \
|
||||
mock::detail::type_name( BOOST_SP_TYPEID(*this) ), \
|
||||
MOCK_TYPE_NAME(*this), \
|
||||
BOOST_PP_STRINGIZE(t) ); \
|
||||
return t##_mock_; \
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue