]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/counting_range.cpp
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)
9 // For more information, see http://www.boost.org/libs/range/
11 // Disable a warning from <xutility> since this noise might
12 // stop us detecting a problem in our code.
13 #include <boost/range/counting_range.hpp>
14 #include <boost/range/adaptor/indirected.hpp>
16 #include <boost/test/test_tools.hpp>
17 #include <boost/test/unit_test.hpp>
19 #include <boost/assign.hpp>
25 #include <boost/range/algorithm_ext.hpp>
30 template<class Container
>
31 void counting_range_test_impl(int first
, int last
)
34 for (int i
= first
; i
< last
; ++i
)
35 reference
.push_back(i
);
38 push_back( test
, counting_range(first
, last
) );
40 BOOST_CHECK_EQUAL_COLLECTIONS(
41 reference
.begin(), reference
.end(),
42 test
.begin(), test
.end());
45 template<class Container
>
46 void counting_range_test_impl()
48 counting_range_test_impl
<Container
>(0, 0);
49 counting_range_test_impl
<Container
>(-1, -1);
50 counting_range_test_impl
<Container
>(-1, 0);
51 counting_range_test_impl
<Container
>(0, 1);
52 counting_range_test_impl
<Container
>(-100, 100);
53 counting_range_test_impl
<Container
>(50, 55);
56 void counting_range_test_range()
59 for (int i
= 0; i
< 10; ++i
)
62 std::vector
<std::vector
<int>::iterator
> x
;
63 push_back(x
, counting_range(v
));
66 push_back(t
, x
| boost::adaptors::indirected
);
68 BOOST_CHECK_EQUAL_COLLECTIONS(t
.begin(), t
.end(),
73 void counting_range_test()
75 counting_range_test_impl
<std::vector
<int> >();
76 counting_range_test_impl
<std::list
<int> >();
77 counting_range_test_impl
<std::deque
<int> >();
81 boost::unit_test::test_suite
*
82 init_unit_test_suite(int argc
, char* argv
[])
84 boost::unit_test::test_suite
* test
85 = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.counting_range" );
87 test
->add( BOOST_TEST_CASE( &boost::counting_range_test
) );