forked from boostorg/type_index
Added more tests for checking work of RTTI on/off mixes.
This commit is contained in:
1 parent
5078498c86
commit
6b283076b9
5 files changed
+37
-15
No files matched your search
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#if !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
# include <boost/type_index/type_index_impl.hpp>
|
||||
#else
|
||||
# include <boost/type_index/template_index_impl.hpp>
|
||||
|
||||
@@ -7,11 +7,29 @@
|
||||
import testing ;
|
||||
import feature ;
|
||||
|
||||
|
||||
# Variable that contains all the stuff required for linking against -lboost_unit_test
|
||||
tlib = /boost/test//boost_unit_test_framework/<link>static ;
|
||||
|
||||
lib test_lib_rtti : test_lib.cpp : <link>shared ;
|
||||
lib test_lib_nortti : test_lib.cpp : <link>shared <rtti>off ;
|
||||
# Variable that contains all the stuff required for linking together <rtti>on and <rtti>off
|
||||
compat = <define>BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY ;
|
||||
|
||||
# Making own `nortti` that is link compatible
|
||||
nortti = <toolset>gcc:<cxxflags>-fno-rtti <toolset>clang:<cxxflags>-fno-rtti <toolset>msvc:<cxxflags>/GR- ;
|
||||
|
||||
|
||||
# Making libraries that CANNOT work between rtti-on/rtti-off modules
|
||||
obj test_lib_nortti-obj : test_lib.cpp : <link>shared $(nortti) ;
|
||||
obj test_lib_rtti-obj : test_lib.cpp : <link>shared ;
|
||||
lib test_lib_rtti : test_lib_rtti-obj : <link>shared ;
|
||||
lib test_lib_nortti : test_lib_nortti-obj : <link>shared $(nortti) ;
|
||||
|
||||
# Making libraries that can work between rtti-on/rtti-off modules
|
||||
obj test_lib_nortti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ;
|
||||
obj test_lib_rtti_compat-obj : test_lib.cpp : <link>shared $(nortti) $(compat) ;
|
||||
lib test_lib_nortti_compat : test_lib_nortti_compat-obj : <link>shared $(nortti) $(compat) ;
|
||||
lib test_lib_rtti_compat : test_lib_rtti_compat-obj : <link>shared $(nortti) $(compat) ;
|
||||
|
||||
|
||||
test-suite type_index
|
||||
:
|
||||
@@ -22,18 +40,13 @@ test-suite type_index
|
||||
[ run testing_minimal.cpp $(tlib) ]
|
||||
[ run testing_minimal_no_rtti.cpp $(tlib) : : : <rtti>off ]
|
||||
[ run testing_crossmodule.cpp test_lib_rtti $(tlib) ]
|
||||
[ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : <rtti>off : testing_crossmodule_no_rtti ]
|
||||
|
||||
# Bjam has specific rule for not mixing <rtti>on and <rtti>off binaries, so we can not
|
||||
# just provide `test_lib_nortti` library for `<rtti>on` build. But here are some workarounds:
|
||||
[ link-fail testing_crossmodule.cpp $(tlib)
|
||||
: <linkflags>$(test_lib_nortti.location)/test_lib_nortti
|
||||
: link_fail_rtti_nortti
|
||||
]
|
||||
[ link-fail testing_crossmodule.cpp $(tlib)
|
||||
: <rtti>off <linkflags>$(test_lib_rtti.location)/test_lib_rtti
|
||||
: link_fail_nortti_rtti
|
||||
]
|
||||
[ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : $(nortti) : testing_crossmodule_no_rtti ]
|
||||
|
||||
# Mixing RTTI on and off
|
||||
[ link-fail testing_crossmodule.cpp $(tlib) test_lib_rtti : $(nortti) : link_fail_nortti_rtti ]
|
||||
[ link-fail testing_crossmodule.cpp $(tlib) test_lib_nortti : : link_fail_rtti_nortti ]
|
||||
[ run testing_crossmodule.cpp $(tlib) test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ]
|
||||
[ run testing_crossmodule.cpp $(tlib) test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ]
|
||||
|
||||
# Examples that must work even with RTTI disabled
|
||||
[ run ../examples/registry.cpp : : : <rtti>off : registry_no_rtti ]
|
||||
|
||||
@@ -23,5 +23,9 @@ boost::type_index get_const_user_defined_class() {
|
||||
return boost::type_id_with_cvr<const user_defined_namespace::user_defined>();
|
||||
}
|
||||
|
||||
|
||||
// Just do nothing
|
||||
void accept_typeindex(const boost::type_index&) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ TEST_LIB_DECL boost::type_index get_user_defined_class();
|
||||
TEST_LIB_DECL boost::type_index get_const_integer();
|
||||
TEST_LIB_DECL boost::type_index get_const_user_defined_class();
|
||||
|
||||
// This is required for checking RTTI on/off linkage
|
||||
TEST_LIB_DECL void accept_typeindex(const boost::type_index&);
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TESTS_LIB1_HPP
|
||||
|
||||
@@ -39,5 +39,7 @@ BOOST_AUTO_TEST_CASE(comparing_types_between_modules)
|
||||
BOOST_CHECK_NE(t_const_userdef, test_lib::get_integer());
|
||||
BOOST_CHECK_NE(t_int, test_lib::get_user_defined_class());
|
||||
BOOST_CHECK_NE(t_const_int, test_lib::get_const_user_defined_class());
|
||||
|
||||
test_lib::accept_typeindex(t_int);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user