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/test/test_tools.hpp> |
---|
21 | #include <boost/test/unit_test.hpp> |
---|
22 | #include <string> |
---|
23 | |
---|
24 | using namespace boost; |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | template< class T > |
---|
28 | const T& as_const( const T& r ) |
---|
29 | { |
---|
30 | return r; |
---|
31 | } |
---|
32 | |
---|
33 | void check_const_ranges() |
---|
34 | { |
---|
35 | std::string foo( "foo" ); |
---|
36 | const std::string bar( "bar" ); |
---|
37 | |
---|
38 | BOOST_CHECK( const_begin( foo ) == begin( as_const( foo ) ) ); |
---|
39 | BOOST_CHECK( const_end( foo ) == end( as_const( foo ) ) ); |
---|
40 | BOOST_CHECK( const_rbegin( foo ) == rbegin( as_const( foo ) ) ); |
---|
41 | BOOST_CHECK( const_rend( foo ) == rend( as_const( foo ) ) ); |
---|
42 | |
---|
43 | BOOST_CHECK( const_begin( bar ) == begin( as_const( bar ) ) ); |
---|
44 | BOOST_CHECK( const_end( bar ) == end( as_const( bar ) ) ); |
---|
45 | BOOST_CHECK( const_rbegin( bar ) == rbegin( as_const( bar ) ) ); |
---|
46 | BOOST_CHECK( const_rend( bar ) == rend( as_const( bar ) ) ); |
---|
47 | |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | using boost::unit_test::test_suite; |
---|
53 | |
---|
54 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
---|
55 | { |
---|
56 | test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); |
---|
57 | |
---|
58 | test->add( BOOST_TEST_CASE( &check_const_ranges ) ); |
---|
59 | |
---|
60 | return test; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|