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 | |
---|
12 | #include <boost/detail/workaround.hpp> |
---|
13 | |
---|
14 | #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) |
---|
15 | # pragma warn -8091 // supress warning in Boost.Test |
---|
16 | # pragma warn -8057 // unused argument argc/argv in Boost.Test |
---|
17 | #endif |
---|
18 | |
---|
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> |
---|
24 | #include <iostream> |
---|
25 | |
---|
26 | using namespace boost; |
---|
27 | using namespace std; |
---|
28 | |
---|
29 | void check_array() |
---|
30 | { |
---|
31 | const int sz = 9; |
---|
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 }; |
---|
35 | |
---|
36 | |
---|
37 | // BOOST_RANGE_NO_STATIC_ASSERT |
---|
38 | #if !defined( __BORLANDC__ ) |
---|
39 | #else |
---|
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_result_iterator<array_t>::type, int* >::value )); |
---|
46 | BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const array_t>::type, const int* >::value )); |
---|
47 | |
---|
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_result_iterator<const array_t>::type, const int* >::value )); |
---|
54 | BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const array_t>::type, const int* >::value )); |
---|
55 | #endif |
---|
56 | |
---|
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 ); |
---|
60 | |
---|
61 | BOOST_CHECK_EQUAL( begin( ca ), ca ); |
---|
62 | BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) ); |
---|
63 | BOOST_CHECK_EQUAL( empty( ca ),false ); |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | using boost::unit_test::test_suite; |
---|
68 | |
---|
69 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
---|
70 | { |
---|
71 | test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); |
---|
72 | |
---|
73 | test->add( BOOST_TEST_CASE( &check_array ) ); |
---|
74 | |
---|
75 | return test; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|