1// Copyright Neil Groves 2009. Use, modification and
2// distribution is subject to the Boost Software License, Version
3// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5//
6//
7// For more information, see http://www.boost.org/libs/range/
8//
9#include <boost/range/algorithm/reverse.hpp>
10
11#include <boost/test/test_tools.hpp>
12#include <boost/test/unit_test.hpp>
13
14#include <boost/assign.hpp>
15#include <algorithm>
16#include <functional>
17#include <list>
18#include <numeric>
19#include <deque>
20#include <vector>
21
22namespace boost
23{
24 namespace
25 {
26 template<class Container>
27 void test_reverse_impl(Container& cont)
28 {
29 Container reference(cont);
30 Container test(cont);
31 Container test2(cont);
32
33 boost::reverse(test);
34 std::reverse(reference.begin(), reference.end());
35 BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
36 test.begin(), test.end() );
37
38 boost::reverse(boost::make_iterator_range(test2));
39 BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
40 test2.begin(), test2.end() );
41 }
42
43 template<class Container>
44 void test_reverse_impl()
45 {
46 using namespace boost::assign;
47
48 Container cont;
49 test_reverse_impl(cont);
50
51 cont.clear();
52 cont += 1;
53 test_reverse_impl(cont);
54
55 cont.clear();
56 cont += 1,2,3,4,5,6,7,8,9;
57 test_reverse_impl(cont);
58 }
59
60 void test_reverse()
61 {
62 test_reverse_impl< std::vector<int> >();
63 test_reverse_impl< std::list<int> >();
64 test_reverse_impl< std::deque<int> >();
65 }
66 }
67}
68
69
70boost::unit_test::test_suite*
71init_unit_test_suite(int argc, char* argv[])
72{
73 boost::unit_test::test_suite* test
74 = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.reverse" );
75
76 test->add( BOOST_TEST_CASE( &boost::test_reverse ) );
77
78 return test;
79}
80

source code of boost/libs/range/test/algorithm_test/reverse.cpp