• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(BOOST_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
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 
check_std_container()27 void check_std_container()
28 {
29     typedef std::vector<int> vec_t;
30     vec_t                    vec;
31     vec.push_back( 3 ); vec.push_back( 4 );
32     const vec_t              cvec( vec );
33 
34     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<vec_t>::type, vec_t::value_type >::value ));
35     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<vec_t>::type, vec_t::iterator >::value ));
36     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
37     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<vec_t>::type, vec_t::difference_type >::value ));
38     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<vec_t>::type, vec_t::size_type >::value ));
39     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<vec_t>::type, vec_t::iterator >::value ));
40     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
41 
42     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<const vec_t>::type, vec_t::value_type >::value ));
43     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<const vec_t>::type, vec_t::difference_type >::value ));
44     BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<const vec_t>::type, vec_t::size_type >::value ));
45 
46     BOOST_CHECK( boost::begin( vec ) == vec.begin() );
47     BOOST_CHECK( boost::end( vec )   == vec.end() );
48     BOOST_CHECK( boost::empty( vec ) == vec.empty() );
49     BOOST_CHECK( static_cast<std::size_t>(boost::size( vec )) == vec.size() );
50 
51     BOOST_CHECK( boost::begin( cvec ) == cvec.begin() );
52     BOOST_CHECK( boost::end( cvec )   == cvec.end() );
53     BOOST_CHECK( boost::empty( cvec ) == cvec.empty() );
54     BOOST_CHECK( static_cast<std::size_t>(boost::size( cvec )) == cvec.size() );
55 
56 }
57 
58 
59 #include <boost/test/unit_test.hpp>
60 
init_unit_test_suite(int argc,char * argv[])61 boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
62 {
63     boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
64 
65     test->add( BOOST_TEST_CASE( &check_std_container ) );
66 
67     return test;
68 }
69 
70 
71 
72 
73 
74 
75