Fix some typos in docs.

Added stricter tests.
All merged from Trunk.

[SVN r54207]
This commit is contained in:
John Maddock committed 2009-06-22 12:18:04 +00:00
1 parent afe1661308
commit 96cbc09229
32 files changed
+213 -43

No files matched your search

+125
View File
@@ -0,0 +1,125 @@
// (C) Copyright Thorsten Ottosen 2009.
// 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>
# include <boost/type_traits/type_with_alignment.hpp> // max_align and long_long_type
#else
# include <boost/type_traits/alignment_of.hpp>
# include <boost/type_traits/aligned_storage.hpp>
# include <boost/type_traits/is_pod.hpp>
#endif
namespace
{
template< unsigned N, unsigned Alignment >
struct alignment_implementation1
{
boost::detail::aligned_storage::aligned_storage_imp<N,Alignment> type;
const void* address() const { return this; }
};
template< unsigned N, unsigned Alignment >
struct alignment_implementation2 :
#ifndef __BORLANDC__
private
#else
public
#endif
boost::detail::aligned_storage::aligned_storage_imp<N,Alignment>
{
typedef boost::detail::aligned_storage::aligned_storage_imp<N,Alignment> type;
const void* address() const { return static_cast<const type*>(this)->address(); }
};
template< unsigned N, class T >
const void* get_address1()
{
alignment_implementation1<N*sizeof(T), tt::alignment_of<T>::value> imp1;
return imp1.address();
}
template< unsigned N, class T >
const void* get_address2()
{
alignment_implementation2<N*sizeof(T), tt::alignment_of<T>::value> imp2;
return imp2.address();
}
template< class T >
void check()
{
const void* addr1 = get_address1<0,T>();
const void* addr2 = get_address2<0,T>();
//
// @remark: only the empty case differs
//
BOOST_CHECK( addr1 != addr2 );
addr1 = get_address1<1,T>();
addr2 = get_address2<1,T>();
BOOST_CHECK( addr1 == addr2 );
addr1 = get_address1<2,T>();
addr2 = get_address2<2,T>();
BOOST_CHECK( addr1 == addr2 );
addr1 = get_address1<3,T>();
addr2 = get_address2<3,T>();
BOOST_CHECK( addr1 == addr2 );
addr1 = get_address1<4,T>();
addr2 = get_address2<4,T>();
BOOST_CHECK( addr1 == addr2 );
addr1 = get_address1<17,T>();
addr2 = get_address2<17,T>();
BOOST_CHECK( addr1 == addr2 );
addr1 = get_address1<32,T>();
addr2 = get_address2<32,T>();
BOOST_CHECK( addr1 == addr2 );
}
}
TT_TEST_BEGIN(type_with_empty_alignment_buffer)
check<char>();
check<short>();
check<int>();
check<long>();
check<float>();
check<double>();
check<long double>();
#ifdef BOOST_HAS_MS_INT64
check<__int64>();
#endif
check<int(*)(int)>();
check<int*>();
check<VB>();
check<VD>();
check<enum_UDT>();
check<mf2>();
check<POD_UDT>();
check<empty_UDT>();
check<union_UDT>();
check<boost::detail::max_align>();
TT_TEST_END
+3
View File
@@ -66,6 +66,9 @@ void check(const T&)
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_CHECK(::tt::is_pod<t3>::value == true);
#endif
BOOST_CHECK(as3.address() == &as3);
const t3 as4 = { 0, };
BOOST_CHECK(as4.address() == static_cast<const void*>(&as4));
#endif
}
+39
View File
@@ -0,0 +1,39 @@
// Copyright 2009 Alexander Nasonov.
// Distributed under 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)
// Test bug 99776 'enum UIntEnum { value = UINT_MAX } is promoted to int'
// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=22b0a6b7-120f-4ca0-9136-fa1b25b26efe
//
// Intel 9.0.028 for Windows has a similar problem:
// https://premier.intel.com/IssueDetail.aspx?IssueID=365073
#include <boost/type_traits/promote.hpp>
#include <climits>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include "promote_util.hpp"
enum UIntEnum { UIntEnum_max = UINT_MAX };
template<class T>
void assert_is_uint(T)
{
BOOST_STATIC_ASSERT((boost::is_same<T, unsigned int>::value));
}
void test_promote_to_uint()
{
assert_is_uint(+UIntEnum_max);
test_cv< UIntEnum, unsigned int >();
}
int main()
{
return 0;
}