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