Add test for typeid(struct X) across libraries

This commit is contained in:
Peter Dimov 2021-02-11 04:43:05 +02:00
parent 1c43651533
commit 2e5ecbe6f6
3 changed files with 49 additions and 0 deletions

View File

@ -215,6 +215,12 @@ run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run test_lib_typeid2.cpp lib_typeid : : : <link>shared : test_lib_typeid2_shared ;
run test_lib_typeid2.cpp lib_typeid : : : <link>static : test_lib_typeid2_static ;
run test_lib_typeid2.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid2_shared_no_rtti ;
run test_lib_typeid2.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid2_static_no_rtti ;
run uncaught_exceptions.cpp
: : : <exception-handling>on ;
run uncaught_exceptions_np.cpp

View File

@ -15,3 +15,12 @@ EXPORT boost::core::typeinfo const & get_typeid_int()
{
return BOOST_CORE_TYPEID( int );
}
struct BOOST_SYMBOL_VISIBLE X
{
};
EXPORT boost::core::typeinfo const & get_typeid_X()
{
return BOOST_CORE_TYPEID( X );
}

34
test/test_lib_typeid2.cpp Normal file
View File

@ -0,0 +1,34 @@
// Copyright 2018, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/typeinfo.hpp>
#include <boost/core/lightweight_test.hpp>
boost::core::typeinfo const & get_typeid_X();
struct BOOST_SYMBOL_VISIBLE X
{
};
struct Y
{
};
int main()
{
boost::core::typeinfo const & tx = BOOST_CORE_TYPEID( X );
boost::core::typeinfo const & ty = BOOST_CORE_TYPEID( Y );
boost::core::typeinfo const & tx2 = get_typeid_X();
BOOST_TEST( tx2 == tx );
BOOST_TEST( tx2 != ty );
BOOST_TEST( !tx2.before( tx ) );
BOOST_TEST( !tx.before( tx2 ) );
BOOST_TEST( tx2.before( ty ) != ty.before( tx2 ) );
return boost::report_errors();
}