1 
2 // Copyright Aleksey Gurtovoy 2001-2006
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/libs/mpl for documentation.
9 
10 // $Id$
11 // $Date$
12 // $Revision$
13 
14 #include <boost/mpl/next_prior.hpp>
15 #include <boost/mpl/aux_/test.hpp>
16 #include <boost/mpl/aux_/config/workaround.hpp>
17 
18 #include <cassert>
19 
20 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
21 #   define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
22     BOOST_TEST(( WRAPPER(T,i)() == i )); \
23     BOOST_TEST(( WRAPPER(T,i)::value == i )); \
24     /**/
25 #else
26 #   define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
27     BOOST_TEST(( WRAPPER(T,i)::value == i )); \
28     /**/
29 #endif
30 
31 #if defined(BOOST_NO_CXX11_CONSTEXPR)
32 #define CONSTEXPR_INTEGRAL_TEST(T, i)
33 #else
34 #define CONSTEXPR_INTEGRAL_TEST(T, i) { static_assert(T() == i, "Constexpr for integral constant failed"); }
35 #endif
36 
37 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
38 // agurt 20/nov/06: see http://article.gmane.org/gmane.comp.lib.boost.devel/151065
39 #define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
40     { \
41       typedef WRAPPER(T,i) borland_tested_type; \
42     { typedef is_same< borland_tested_type::value_type, T > borland_test_type; \
43       MPL_ASSERT(( borland_test_type )); } \
44     { MPL_ASSERT(( is_same< borland_tested_type::type, WRAPPER(T,i) > )); } \
45     { MPL_ASSERT(( is_same< next< borland_tested_type >::type, WRAPPER(T,i+1) > )); } \
46     { MPL_ASSERT(( is_same< prior< borland_tested_type >::type, WRAPPER(T,i-1) > )); } \
47     { MPL_ASSERT_RELATION( (borland_tested_type::value), ==, i ); } \
48     CONSTEXPR_INTEGRAL_TEST(borland_tested_type, i) \
49     INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
50     } \
51 /**/
52 #else
53 #define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
54     { MPL_ASSERT(( is_same< WRAPPER(T,i)::value_type, T > )); } \
55     { MPL_ASSERT(( is_same< WRAPPER(T,i)::type, WRAPPER(T,i) > )); } \
56     { MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \
57     { MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \
58     { MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \
59     CONSTEXPR_INTEGRAL_TEST(WRAPPER(T,i), i) \
60     INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
61 /**/
62 #endif
63 
64