| 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/functions.hpp> |
|---|
| 20 | #include <boost/range/metafunctions.hpp> |
|---|
| 21 | #include <boost/static_assert.hpp> |
|---|
| 22 | #include <boost/type_traits.hpp> |
|---|
| 23 | #include <boost/test/unit_test.hpp> |
|---|
| 24 | #include <boost/test/test_tools.hpp> |
|---|
| 25 | #include <vector> |
|---|
| 26 | |
|---|
| 27 | using namespace boost; |
|---|
| 28 | |
|---|
| 29 | void check_std_container() |
|---|
| 30 | { |
|---|
| 31 | typedef std::vector<int> vec_t; |
|---|
| 32 | vec_t vec; |
|---|
| 33 | vec.push_back( 3 ); vec.push_back( 4 ); |
|---|
| 34 | const vec_t cvec( vec ); |
|---|
| 35 | |
|---|
| 36 | BOOST_STATIC_ASSERT(( is_same< range_value<vec_t>::type, vec_t::value_type >::value )); |
|---|
| 37 | BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value )); |
|---|
| 38 | BOOST_STATIC_ASSERT(( is_same< range_const_iterator<vec_t>::type, vec_t::const_iterator >::value )); |
|---|
| 39 | BOOST_STATIC_ASSERT(( is_same< range_difference<vec_t>::type, vec_t::difference_type >::value )); |
|---|
| 40 | BOOST_STATIC_ASSERT(( is_same< range_size<vec_t>::type, vec_t::size_type >::value )); |
|---|
| 41 | BOOST_STATIC_ASSERT(( is_same< range_result_iterator<vec_t>::type, vec_t::iterator >::value )); |
|---|
| 42 | BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const vec_t>::type, vec_t::const_iterator >::value )); |
|---|
| 43 | |
|---|
| 44 | BOOST_STATIC_ASSERT(( is_same< range_value<const vec_t>::type, vec_t::value_type >::value )); |
|---|
| 45 | BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::iterator >::value )); |
|---|
| 46 | BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const vec_t>::type, vec_t::const_iterator >::value )); |
|---|
| 47 | BOOST_STATIC_ASSERT(( is_same< range_difference<const vec_t>::type, vec_t::difference_type >::value )); |
|---|
| 48 | BOOST_STATIC_ASSERT(( is_same< range_size<const vec_t>::type, vec_t::size_type >::value )); |
|---|
| 49 | |
|---|
| 50 | BOOST_CHECK( begin( vec ) == vec.begin() ); |
|---|
| 51 | BOOST_CHECK( end( vec ) == vec.end() ); |
|---|
| 52 | BOOST_CHECK( empty( vec ) == vec.empty() ); |
|---|
| 53 | BOOST_CHECK( size( vec ) == vec.size() ); |
|---|
| 54 | |
|---|
| 55 | BOOST_CHECK( begin( cvec ) == cvec.begin() ); |
|---|
| 56 | BOOST_CHECK( end( cvec ) == cvec.end() ); |
|---|
| 57 | BOOST_CHECK( empty( cvec ) == cvec.empty() ); |
|---|
| 58 | BOOST_CHECK( size( cvec ) == cvec.size() ); |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | #include <boost/test/unit_test.hpp> |
|---|
| 64 | using boost::unit_test::test_suite; |
|---|
| 65 | |
|---|
| 66 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
|---|
| 67 | { |
|---|
| 68 | test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); |
|---|
| 69 | |
|---|
| 70 | test->add( BOOST_TEST_CASE( &check_std_container ) ); |
|---|
| 71 | |
|---|
| 72 | return test; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|