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 | //[adjacent_filtered_example |
12 | #include <boost/range/adaptor/adjacent_filtered.hpp> |
13 | #include <boost/range/algorithm/copy.hpp> |
14 | #include <boost/assign.hpp> |
15 | #include <iterator> |
16 | #include <functional> |
17 | #include <iostream> |
18 | #include <vector> |
19 | |
20 | //<- |
21 | #include <boost/range/algorithm_ext/push_back.hpp> |
22 | |
23 | #include <boost/test/test_tools.hpp> |
24 | #include <boost/test/unit_test.hpp> |
25 | |
26 | namespace |
27 | { |
28 | void adjacent_filtered_example_test() |
29 | //-> |
30 | //=int main(int argc, const char* argv[]) |
31 | { |
32 | using namespace boost::assign; |
33 | using namespace boost::adaptors; |
34 | |
35 | std::vector<int> input; |
36 | input += 1,1,2,2,2,3,4,5,6; |
37 | |
38 | boost::copy( |
39 | rng: input | adjacent_filtered(std::not_equal_to<int>()), |
40 | out: std::ostream_iterator<int>(std::cout, "," )); |
41 | |
42 | //= return 0; |
43 | //=} |
44 | //] |
45 | std::vector<int> reference; |
46 | reference += 1,2,3,4,5,6; |
47 | |
48 | std::vector<int> test; |
49 | boost::push_back(on&: test, from: input | adjacent_filtered(std::not_equal_to<int>())); |
50 | |
51 | BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), |
52 | test.begin(), test.end() ); |
53 | } |
54 | } |
55 | |
56 | boost::unit_test::test_suite* |
57 | init_unit_test_suite(int argc, char* argv[]) |
58 | { |
59 | boost::unit_test::test_suite* test |
60 | = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.adjacent_filtered_example" ); |
61 | |
62 | test->add( BOOST_TEST_CASE( &adjacent_filtered_example_test ) ); |
63 | |
64 | return test; |
65 | } |
66 | |