]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/partial_workaround.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / range / test / partial_workaround.cpp
1 // Boost.Range library
2 //
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // For more information, see http://www.boost.org/libs/range/
9 //
10
11 #include <boost/config.hpp>
12 #include <boost/detail/workaround.hpp>
13 #include <boost/range/detail/implementation_help.hpp>
14 #include <boost/test/test_tools.hpp>
15
16 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
17 # pragma warn -8091 // suppress warning in Boost.Test
18 # pragma warn -8057 // unused argument argc/argv in Boost.Test
19 #endif
20
21 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
22 //#define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 1
23
24 #include <boost/range/iterator.hpp>
25 #include <boost/range/const_iterator.hpp>
26 #include <boost/range/size_type.hpp>
27 #include <boost/range/value_type.hpp>
28 #include <boost/range/difference_type.hpp>
29
30 #include <boost/range/functions.hpp>
31 #include <boost/range/detail/sfinae.hpp>
32
33 #include <boost/static_assert.hpp>
34 #include <boost/type_traits.hpp>
35 #include <iostream>
36 #include <vector>
37
38 using namespace boost;
39 using namespace std;
40
41 void check_partial_workaround()
42 {
43 using namespace range_detail;
44 using type_traits::yes_type;
45 using type_traits::no_type;
46
47 //////////////////////////////////////////////////////////////////////
48 // string
49 //////////////////////////////////////////////////////////////////////
50 char* c_ptr;
51 const char* cc_ptr;
52 wchar_t* w_ptr;
53 const wchar_t* cw_ptr;
54
55 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( c_ptr ) ) );
56 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cc_ptr ) ) );
57 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( w_ptr ) ) );
58 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cw_ptr ) ) );
59
60 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_char_ptr_impl( c_ptr ) ) );
61 BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_char_ptr_impl( cc_ptr ) ) );
62
63 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_wchar_t_ptr_impl( w_ptr ) ) );
64 BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_wchar_t_ptr_impl( cw_ptr ) ) );
65
66 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( c_ptr ) ) );
67 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( cc_ptr ) ) );
68
69 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( w_ptr ) ) );
70 BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( cw_ptr ) ) );
71
72 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_,
73 boost::range_detail::range< vector<int> >::type >::value ));
74 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_pair_,
75 boost::range_detail::range< pair<int,int> >::type >::value ));
76 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::array_,
77 boost::range_detail::range< int[42] >::type >::value ));
78 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::char_ptr_,
79 boost::range_detail::range< char* >::type >::value ));
80 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_char_ptr_,
81 boost::range_detail::range< const char* >::type >::value ));
82 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::wchar_t_ptr_,
83 boost::range_detail::range< wchar_t* >::type >::value ));
84 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_wchar_t_ptr_,
85 boost::range_detail::range< const wchar_t* >::type >::value ));
86 BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_,
87 boost::range_detail::range< vector<int> >::type >::value ));
88
89 }
90
91 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
92
93 void check_partial_workaround()
94 {
95 //
96 // test if warnings are generated
97 //
98 std::size_t s = boost::range_detail::array_size( "foo" );
99 BOOST_CHECK_EQUAL( s, 4u );
100 }
101
102 #endif
103
104 #include <boost/test/unit_test.hpp>
105 using boost::unit_test::test_suite;
106
107 test_suite* init_unit_test_suite( int argc, char* argv[] )
108 {
109 test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
110
111 test->add( BOOST_TEST_CASE( &check_partial_workaround ) );
112
113 return test;
114 }