Fix test to compare typeinfo rather than its address

This commit is contained in:
Peter Dimov 2018-10-21 18:44:34 +03:00
parent 3c9c9603ad
commit 4dc12c59bd
2 changed files with 16 additions and 4 deletions

View File

@ -11,7 +11,7 @@
# define EXPORT
#endif
EXPORT boost::core::typeinfo const * get_typeid_int()
EXPORT boost::core::typeinfo const & get_typeid_int()
{
return &BOOST_CORE_TYPEID( int );
return BOOST_CORE_TYPEID( int );
}

View File

@ -5,10 +5,22 @@
#include <boost/core/typeinfo.hpp>
#include <boost/core/lightweight_test.hpp>
boost::core::typeinfo const * get_typeid_int();
boost::core::typeinfo const & get_typeid_int();
int main()
{
BOOST_TEST_EQ( get_typeid_int(), &BOOST_CORE_TYPEID( int ) );
boost::core::typeinfo const & ti = BOOST_CORE_TYPEID( int );
boost::core::typeinfo const & tf = BOOST_CORE_TYPEID( float );
boost::core::typeinfo const & ti2 = get_typeid_int();
BOOST_TEST( ti2 == ti );
BOOST_TEST( ti2 != tf );
BOOST_TEST( !ti2.before( ti ) );
BOOST_TEST( !ti.before( ti2 ) );
BOOST_TEST( ti2.before( tf ) != tf.before( ti2 ) );
return boost::report_errors();
}