Updated and strengthened type_with_alignment tests and fixed msvc issue that prevented a type_with_alignment (or any type containing it such as Boost.Optional) from being passed by value. See http://article.gmane.org/gmane.comp.lib.boost.devel/173011 for motivating test case.

[SVN r43984]
This commit is contained in:
John Maddock committed 2008-04-01 16:48:58 +00:00
1 parent 9f60cc0b42
commit 912045e6ac
2 files changed
+146 -218

No files matched your search

+56 -207
View File
@@ -25,227 +25,76 @@ struct __declspec(align(64)) a64 { char m[64]; };
struct __declspec(align(128)) a128 { char m[128]; };
#endif
void check_call2(...){}
template <class T>
void check_call(const T& v)
{
check_call2(v);
}
#define TYPE_WITH_ALIGNMENT_TEST(T)\
{\
BOOST_CHECK(::tt::alignment_of<\
::tt::type_with_alignment<\
::tt::alignment_of< T >::value\
>::type\
>::value == ::boost::alignment_of< T >::value);\
BOOST_CHECK(::tt::is_pod<\
::tt::type_with_alignment<\
::tt::alignment_of< T >::value>::type\
>::value);\
}
#define TYPE_WITH_ALIGNMENT_TEST_EX(T)\
TYPE_WITH_ALIGNMENT_TEST(T)\
{\
::tt::type_with_alignment<\
::tt::alignment_of< T >::value\
>::type val;\
check_call(val);\
}
TT_TEST_BEGIN(type_with_alignment)
BOOST_MESSAGE(typeid(::tt::type_with_alignment<
::tt::alignment_of<char>::value
>::type).name());
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<char>::value
>::type
>::value == ::boost::alignment_of<char>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<short>::value
>::type
>::value == ::boost::alignment_of<short>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<int>::value
>::type
>::value == ::boost::alignment_of<int>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<long>::value
>::type
>::value == ::boost::alignment_of<long>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<float>::value
>::type
>::value == ::boost::alignment_of<float>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<double>::value
>::type
>::value == ::boost::alignment_of<double>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<long double>::value
>::type
>::value == ::boost::alignment_of<long double>::value);
TYPE_WITH_ALIGNMENT_TEST_EX(char)
TYPE_WITH_ALIGNMENT_TEST_EX(short)
TYPE_WITH_ALIGNMENT_TEST_EX(int)
TYPE_WITH_ALIGNMENT_TEST_EX(long)
TYPE_WITH_ALIGNMENT_TEST_EX(float)
TYPE_WITH_ALIGNMENT_TEST_EX(double)
TYPE_WITH_ALIGNMENT_TEST_EX(long double)
#ifdef BOOST_HAS_LONG_LONG
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of< ::boost::long_long_type>::value
>::type
>::value == ::boost::alignment_of< ::boost::long_long_type>::value);
TYPE_WITH_ALIGNMENT_TEST_EX(::boost::long_long_type)
#endif
#ifdef BOOST_HAS_MS_INT64
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<__int64>::value
>::type
>::value == ::boost::alignment_of<__int64>::value);
TYPE_WITH_ALIGNMENT_TEST_EX(__int64)
#endif
TYPE_WITH_ALIGNMENT_TEST_EX(int[4])
TYPE_WITH_ALIGNMENT_TEST_EX(int(*)(int))
TYPE_WITH_ALIGNMENT_TEST_EX(int*)
TYPE_WITH_ALIGNMENT_TEST_EX(VB)
TYPE_WITH_ALIGNMENT_TEST_EX(VD)
TYPE_WITH_ALIGNMENT_TEST_EX(enum_UDT)
TYPE_WITH_ALIGNMENT_TEST_EX(mf2)
TYPE_WITH_ALIGNMENT_TEST_EX(POD_UDT)
TYPE_WITH_ALIGNMENT_TEST_EX(empty_UDT)
TYPE_WITH_ALIGNMENT_TEST_EX(union_UDT)
#if defined(BOOST_MSVC) || (defined(BOOST_INTEL) && defined(_MSC_VER))
#if _MSC_VER >= 1400
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<__m128>::value
>::type
>::value == ::boost::alignment_of<__m128>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<__m64>::value
>::type
>::value == ::boost::alignment_of<__m64>::value);
TYPE_WITH_ALIGNMENT_TEST(__m128)
TYPE_WITH_ALIGNMENT_TEST(__m64)
#endif
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<a8>::value
>::type
>::value == ::boost::alignment_of<a8>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<a16>::value
>::type
>::value == ::boost::alignment_of<a16>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<a32>::value
>::type
>::value == ::boost::alignment_of<a32>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<a64>::value
>::type
>::value == ::boost::alignment_of<a64>::value);
TYPE_WITH_ALIGNMENT_TEST(a8)
TYPE_WITH_ALIGNMENT_TEST(a16)
TYPE_WITH_ALIGNMENT_TEST(a32)
#endif
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<int[4]>::value
>::type
>::value == ::boost::alignment_of<int[4]>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<int(*)(int)>::value
>::type
>::value == ::boost::alignment_of<int(*)(int)>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<int*>::value
>::type
>::value == ::boost::alignment_of<int*>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<VB>::value
>::type
>::value == ::boost::alignment_of<VB>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<VD>::value
>::type
>::value == ::boost::alignment_of<VD>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<enum_UDT>::value
>::type
>::value == ::boost::alignment_of<enum_UDT>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<mf2>::value
>::type
>::value == ::boost::alignment_of<mf2>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<POD_UDT>::value
>::type
>::value == ::boost::alignment_of<POD_UDT>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<empty_UDT>::value
>::type
>::value == ::boost::alignment_of<empty_UDT>::value);
BOOST_CHECK(::tt::alignment_of<
::tt::type_with_alignment<
::tt::alignment_of<union_UDT>::value
>::type
>::value == ::boost::alignment_of<union_UDT>::value);
// check that the type produced are POD's:
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<char>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<short>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<int>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<long>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<float>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<double>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<long double>::value>::type
>::value);
#ifdef BOOST_HAS_LONG_LONG
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of< ::boost::long_long_type>::value>::type
>::value);
#endif
#ifdef BOOST_HAS_MS_INT64
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<__int64>::value>::type
>::value);
#endif
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<int[4]>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<int(*)(int)>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<int*>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<VB>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<VD>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<enum_UDT>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<mf2>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<POD_UDT>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<empty_UDT>::value>::type
>::value);
BOOST_CHECK(::tt::is_pod<
::tt::type_with_alignment<
::tt::alignment_of<union_UDT>::value>::type
>::value);
TT_TEST_END