Added missing tests, made std test mode TR1 conforming.

[SVN r26959]
This commit is contained in:
John Maddock
2005-01-31 13:49:34 +00:00
parent 119a76547b
commit 0a79e9cb27
3 changed files with 126 additions and 1 deletions

53
test/add_cv_test.cpp Normal file
View File

@ -0,0 +1,53 @@
// (C) Copyright John Maddock 2005.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "test.hpp"
#include "check_type.hpp"
#ifdef TEST_STD
# include <type_traits>
#else
# include <boost/type_traits/add_cv.hpp>
#endif
BOOST_DECL_TRANSFORM_TEST(add_cv_test_1, ::boost::add_cv, const, const volatile)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_2, ::boost::add_cv, volatile, volatile const)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_3, ::boost::add_cv, *, *const volatile)
BOOST_DECL_TRANSFORM_TEST2(add_cv_test_4, ::boost::add_cv, const volatile)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_7, ::boost::add_cv, *volatile, *volatile const)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_10, ::boost::add_cv, const*, const*const volatile)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_11, ::boost::add_cv, volatile*, volatile*const volatile )
BOOST_DECL_TRANSFORM_TEST(add_cv_test_5, ::boost::add_cv, const &, const&)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_6, ::boost::add_cv, &, &)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_8, ::boost::add_cv, const [2], const volatile [2])
BOOST_DECL_TRANSFORM_TEST(add_cv_test_9, ::boost::add_cv, volatile &, volatile&)
BOOST_DECL_TRANSFORM_TEST(add_cv_test_12, ::boost::add_cv, [2][3], const volatile[2][3])
BOOST_DECL_TRANSFORM_TEST(add_cv_test_13, ::boost::add_cv, (&)[2], (&)[2])
TT_TEST_BEGIN(add_const)
add_cv_test_1();
add_cv_test_2();
add_cv_test_3();
add_cv_test_4();
add_cv_test_7();
add_cv_test_10();
add_cv_test_11();
add_cv_test_5();
add_cv_test_6();
add_cv_test_8();
add_cv_test_9();
add_cv_test_12();
add_cv_test_13();
TT_TEST_END

View File

@ -0,0 +1,72 @@
// (C) Copyright John Maddock 2000.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "test.hpp"
#include "check_integral_constant.hpp"
#ifdef TEST_STD
# include <type_traits>
#else
# include <boost/type_traits/alignment_of.hpp>
# include <boost/type_traits/aligned_storage.hpp>
# include <boost/type_traits/is_pod.hpp>
#endif
template <class T>
void check(const T&)
{
typedef typename tt::aligned_storage<T::value,T::value>::type t1;
BOOST_MESSAGE(typeid(t1).name());
BOOST_CHECK(::tt::alignment_of<t1>::value == T::value);
BOOST_CHECK(sizeof(t1) == T::value);
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_CHECK(::tt::is_pod<t1>::value == true);
#endif
typedef typename tt::aligned_storage<T::value*2,T::value>::type t2;
BOOST_MESSAGE(typeid(t2).name());
BOOST_CHECK(::tt::alignment_of<t2>::value == T::value);
BOOST_CHECK(sizeof(t2) == T::value*2);
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_CHECK(::tt::is_pod<t2>::value == true);
#endif
}
TT_TEST_BEGIN(type_with_alignment)
check(tt::integral_constant<std::size_t,::tt::alignment_of<char>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<short>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<int>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<long>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<float>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<double>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<long double>::value>());
#ifdef BOOST_HAS_LONG_LONG
check(tt::integral_constant<std::size_t,::tt::alignment_of< ::boost::long_long_type>::value>());
#endif
#ifdef BOOST_HAS_MS_INT64
check(tt::integral_constant<std::size_t,::tt::alignment_of<__int64>::value>());
#endif
check(tt::integral_constant<std::size_t,::tt::alignment_of<int[4]>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<int(*)(int)>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<int*>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<VB>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<VD>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<enum_UDT>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<mf2>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<POD_UDT>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<empty_UDT>::value>());
check(tt::integral_constant<std::size_t,::tt::alignment_of<union_UDT>::value>());
TT_TEST_END

View File

@ -24,7 +24,7 @@
//
#ifdef TEST_STD
#define tt std
#define tt std::tr1
//#define TYPE_TRAITS(x) <type_traits>
//#define TYPE_COMPARE(x) <type_compare>