Updated is_convertible test cases to check polymorphic-type conversions.

Added more test types to testing header.
Changed utility code to use new test header.


[SVN r27807]
This commit is contained in:
John Maddock
2005-03-24 18:20:18 +00:00
parent 6a9d90291d
commit 8513618762
2 changed files with 36 additions and 0 deletions

View File

@ -18,6 +18,11 @@ struct convertible_from
convertible_from(T);
};
struct base2 { };
struct middle2 : virtual base2 { };
struct derived2 : middle2 { };
TT_TEST_BEGIN(is_convertible)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<Derived,Base>::value), true);
@ -27,6 +32,18 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<Base,Derived>::value), false
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<Derived,Derived>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<NonDerived,Base>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,int>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<virtual_inherit2,virtual_inherit1>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<VD,VB>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<polymorphic_derived1,polymorphic_base>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<polymorphic_derived2,polymorphic_base>::value), true);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<polymorphic_base,polymorphic_derived1>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<polymorphic_base,polymorphic_derived2>::value), false);
#ifndef BOOST_NO_IS_ABSTRACT
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<test_abc1,test_abc1>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<Base,test_abc1>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<polymorphic_derived2,test_abc1>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int,test_abc1>::value), false);
#endif
// The following four do not compile without member template support:
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,void>::value), false);

View File

@ -309,6 +309,25 @@ struct test_abc3 : public test_abc1
struct incomplete_type;
struct polymorphic_base
{
virtual void method();
};
struct polymorphic_derived1 : polymorphic_base
{
};
struct polymorphic_derived2 : polymorphic_base
{
virtual void method();
};
struct virtual_inherit1 : virtual Base { };
struct virtual_inherit2 : virtual_inherit1 { };
typedef void foo0_t();
typedef void foo1_t(int);
typedef void foo2_t(int&, double);