]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/array.cpp
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)
8 // For more information, see http://www.boost.org/libs/range/
12 #include <boost/detail/workaround.hpp>
14 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
15 # pragma warn -8091 // suppress warning in Boost.Test
16 # pragma warn -8057 // unused argument argc/argv in Boost.Test
19 #include <boost/range.hpp>
20 #include <boost/static_assert.hpp>
21 #include <boost/type_traits.hpp>
22 #include <boost/test/test_tools.hpp>
23 #include <boost/test/unit_test.hpp>
26 using namespace boost
;
32 typedef int array_t
[sz
];
33 int my_array
[sz
] = { 1,2,3,4,5,6,7,8,9 };
34 const array_t ca
= { 1,2,3,4,5,6,7,8,10 };
37 // BOOST_RANGE_NO_STATIC_ASSERT
38 #if !defined( __BORLANDC__ )
40 BOOST_STATIC_ASSERT(( is_same
< range_value
<array_t
>::type
, int >::value
));
41 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<array_t
>::type
, int* >::value
));
42 BOOST_STATIC_ASSERT(( is_same
< range_const_iterator
<array_t
>::type
, const int* >::value
));
43 BOOST_STATIC_ASSERT(( is_same
< range_difference
<array_t
>::type
, std::ptrdiff_t >::value
));
44 BOOST_STATIC_ASSERT(( is_same
< range_size
<array_t
>::type
, std::size_t >::value
));
45 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<array_t
>::type
, int* >::value
));
46 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<const array_t
>::type
, const int* >::value
));
48 BOOST_STATIC_ASSERT(( is_same
< range_value
<const array_t
>::type
, const int >::value
));
49 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<const array_t
>::type
, const int* >::value
));
50 BOOST_STATIC_ASSERT(( is_same
< range_const_iterator
<const array_t
>::type
, const int* >::value
));
51 BOOST_STATIC_ASSERT(( is_same
< range_difference
<const array_t
>::type
, std::ptrdiff_t >::value
));
52 BOOST_STATIC_ASSERT(( is_same
< range_size
<const array_t
>::type
, std::size_t >::value
));
53 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<const array_t
>::type
, const int* >::value
));
54 BOOST_STATIC_ASSERT(( is_same
< range_iterator
<const array_t
>::type
, const int* >::value
));
57 BOOST_CHECK_EQUAL( begin( my_array
), my_array
);
58 BOOST_CHECK_EQUAL( end( my_array
), my_array
+ size( my_array
) );
59 BOOST_CHECK_EQUAL( empty( my_array
), false );
61 BOOST_CHECK_EQUAL( begin( ca
), ca
);
62 BOOST_CHECK_EQUAL( end( ca
), ca
+ size( ca
) );
63 BOOST_CHECK_EQUAL( empty( ca
),false );
65 const char A
[] = "\0A";
66 BOOST_CHECK_EQUAL( boost::size(A
), 3 );
69 using boost::unit_test::test_suite
;
71 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
73 test_suite
* test
= BOOST_TEST_SUITE( "Range Test Suite" );
75 test
->add( BOOST_TEST_CASE( &check_array
) );