Replaced std::type_info with boost::detail::sp_typeinfo

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@553 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2012-09-02 21:31:24 +00:00
parent 8aa007af3b
commit 25ccf6078f
4 changed files with 11 additions and 9 deletions

View file

@ -17,7 +17,7 @@ namespace
template< typename T >
std::string to_string( const T& )
{
return boost::lexical_cast< std::string >( mock::detail::type_name( typeid( T ) ) );
return boost::lexical_cast< std::string >( mock::detail::type_name( BOOST_SP_TYPEID( T ) ) );
}
}
@ -75,5 +75,5 @@ BOOST_AUTO_TEST_CASE( name_of_type_from_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( typeid( my_local_type ) ) ) );
BOOST_CHECK_EQUAL( "my_local_type", boost::lexical_cast< std::string >( mock::detail::type_name( BOOST_SP_TYPEID( my_local_type ) ) ) );
}

View file

@ -32,7 +32,7 @@ namespace
{
fixture()
{
mock::detail::configure( o, e, "instance", mock::detail::type_name( typeid( o ) ), "name" );
mock::detail::configure( o, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( o ) ), "name" );
}
object o;
mock::detail::function< void() > e;
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( an_object_is_assignable_by_sharing_its_state )
mock::detail::function< void() > e;
{
object o2;
mock::detail::configure( o2, e, "instance", mock::detail::type_name( typeid( o2 ) ), "name" );
mock::detail::configure( o2, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( o2 ) ), "name" );
e.expect().once();
o1 = o2;
BOOST_CHECK( ! mock::verify( o2 ) );
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE( an_object_is_copiable_by_sharing_its_state )
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( typeid( *o2 ) ), "name" );
mock::detail::configure( *o2, e, "instance", mock::detail::type_name( BOOST_SP_TYPEID( *o2 ) ), "name" );
e.expect().once();
BOOST_CHECK( ! mock::verify( *o2 ) );
BOOST_CHECK( ! mock::verify( o1 ) );

View file

@ -10,6 +10,7 @@
#define MOCK_TYPE_NAME_HPP_INCLUDED
#include <boost/test/utils/basic_cstring/io.hpp>
#include <boost/detail/sp_typeinfo.hpp>
#include <stdexcept>
#include <typeinfo>
#include <ostream>
@ -25,7 +26,7 @@ namespace detail
class type_name
{
public:
explicit type_name( const std::type_info& info )
explicit type_name( const boost::detail::sp_typeinfo& info )
: info_( &info )
{}
friend std::ostream& operator<<( std::ostream& s, const type_name& t )
@ -34,7 +35,8 @@ namespace detail
return s;
}
private:
void serialize( std::ostream& s, const std::type_info& info ) const
void serialize( std::ostream& s,
const boost::detail::sp_typeinfo& info ) const
{
const char* name = info.name();
#ifdef __GNUC__
@ -76,7 +78,7 @@ namespace detail
s << name;
}
const std::type_info* info_;
const boost::detail::sp_typeinfo* info_;
};
}
} // mock

View file

@ -43,7 +43,7 @@
{ \
mock::detail::configure( *this, t##_mock_, \
instance.substr( 0, instance.rfind( BOOST_PP_STRINGIZE(t) ) ), \
mock::detail::type_name( typeid( *this ) ), \
mock::detail::type_name( BOOST_SP_TYPEID( *this ) ), \
BOOST_PP_STRINGIZE(t) ); \
return t##_mock_; \
}