| 1 | // Boost.Range library |
| 2 | // |
| 3 | // Copyright Neil Groves 2009. 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 | // |
| 9 | // For more information, see http://www.boost.org/libs/range/ |
| 10 | // |
| 11 | //[reversed_example |
| 12 | #include <boost/range/adaptor/reversed.hpp> |
| 13 | #include <boost/range/algorithm/copy.hpp> |
| 14 | #include <boost/assign.hpp> |
| 15 | #include <iterator> |
| 16 | #include <iostream> |
| 17 | #include <vector> |
| 18 | |
| 19 | //<- |
| 20 | #include <boost/test/test_tools.hpp> |
| 21 | #include <boost/test/unit_test.hpp> |
| 22 | |
| 23 | #include <boost/range/algorithm_ext/push_back.hpp> |
| 24 | |
| 25 | namespace |
| 26 | { |
| 27 | void reversed_example_test() |
| 28 | //-> |
| 29 | //=int main(int argc, const char* argv[]) |
| 30 | { |
| 31 | using namespace boost::adaptors; |
| 32 | using namespace boost::assign; |
| 33 | |
| 34 | std::vector<int> input; |
| 35 | input += 1,2,3,4,5,6,7,8,9; |
| 36 | |
| 37 | boost::copy( |
| 38 | rng: input | reversed, |
| 39 | out: std::ostream_iterator<int>(std::cout, "," )); |
| 40 | |
| 41 | //= return 0; |
| 42 | //=} |
| 43 | //] |
| 44 | std::vector<int> test; |
| 45 | boost::push_back(on&: test, from: input | reversed); |
| 46 | |
| 47 | BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(), |
| 48 | test.begin(), test.end() ); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | boost::unit_test::test_suite* |
| 53 | init_unit_test_suite(int argc, char* argv[]) |
| 54 | { |
| 55 | boost::unit_test::test_suite* test |
| 56 | = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.reversed_example" ); |
| 57 | |
| 58 | test->add( BOOST_TEST_CASE( &reversed_example_test ) ); |
| 59 | |
| 60 | return test; |
| 61 | } |
| 62 | |