]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/adaptor_test/sliced_example.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / range / test / adaptor_test / sliced_example.cpp
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 //[sliced_example
12 #include <boost/range/adaptor/sliced.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 sliced_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 input | sliced(2, 5),
39 std::ostream_iterator<int>(std::cout, ","));
40
41 //= return 0;
42 //=}
43 //]
44 std::vector<int> reference;
45 reference += 3,4,5;
46
47 std::vector<int> test;
48 boost::push_back(test, input | sliced(2, 5));
49
50 BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
51 test.begin(), test.end() );
52 }
53 }
54
55 boost::unit_test::test_suite*
56 init_unit_test_suite(int argc, char* argv[])
57 {
58 boost::unit_test::test_suite* test
59 = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.sliced_example" );
60
61 test->add( BOOST_TEST_CASE( &sliced_example_test ) );
62
63 return test;
64 }