Add test for BOOST_CORE_TYPEID in a library

This commit is contained in:
Peter Dimov
2018-10-21 17:47:33 +03:00
parent ada6b9e447
commit 026be7659c
3 changed files with 39 additions and 0 deletions

View File

@ -130,5 +130,13 @@ run empty_value_size_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
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 ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

17
test/lib_typeid.cpp Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/typeinfo.hpp>
#include <boost/config.hpp>
#if defined(LIB_TYPEID_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT boost::core::typeinfo const * get_typeid_int()
{
return &BOOST_CORE_TYPEID( int );
}

14
test/test_lib_typeid.cpp Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2018 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_int();
int main()
{
BOOST_TEST_EQ( get_typeid_int(), &BOOST_CORE_TYPEID( int ) );
return boost::report_errors();
}