1 #define BOOST_TEST_MODULE (Tests of maybeCastObj interface) 2 #include "boost/test/unit_test.hpp" 9 template <
typename T,
typename U>
20 class MCConcrete :
public MCBase {};
25 virtual ~MCBaseVirtual() {}
33 class MCConcreteVirtual_A :
public MCBaseVirtual {
35 virtual ~MCConcreteVirtual_A() {}
43 class MCConcreteVirtual_B :
public MCBaseVirtual {
45 virtual ~MCConcreteVirtual_B() {}
53 class MCConcreteVirtual_C :
public MCConcreteVirtual_B,
public MCConcrete {
55 virtual ~MCConcreteVirtual_C() {}
67 class MCConcreteMultiple :
public MCBase,
public MCOtherBase {};
72 BOOST_AUTO_TEST_SUITE(maybeCastObj_t)
115 (!runUpcastAllowed<MCConcreteVirtual_B, MCConcreteVirtual_A>()));
119 (runUpcastAllowed<MCConcreteVirtual_C, MCConcreteVirtual_B>()));
130 MCConcrete actualConcrete{};
131 MCBase& refToBase = actualConcrete;
136 MCConcreteVirtual_A actualConcreteVirtual{};
137 MCBaseVirtual& refToBaseVirtual = actualConcreteVirtual;
139 typeid(MCConcreteVirtual_A))));
141 typeid(refToBaseVirtual),
typeid(MCConcreteVirtual_B))));
144 BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
BOOST_AUTO_TEST_CASE(identical_types)
bool upcastAllowed(std::type_info const &tiFrom, std::type_info const &tiTo)