]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/algorithm_ext_test/push_front.cpp
3 // Copyright Neil Groves 2010. 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 #include <boost/range/algorithm_ext/push_front.hpp>
13 #include <boost/test/test_tools.hpp>
14 #include <boost/test/unit_test.hpp>
16 #include <boost/range/iterator.hpp>
17 #include <boost/range/irange.hpp>
26 template< class Value
>
27 Value
operator()(Value x
)
33 template< class Container
>
34 void test_push_front_impl(std::size_t n
)
37 for (std::size_t i
= 0; i
< n
; ++i
)
38 reference
.push_back(i
);
41 boost::push_front(test
, boost::irange
<std::size_t>(0, n
));
43 BOOST_CHECK_EQUAL_COLLECTIONS( reference
.begin(), reference
.end(),
44 test
.begin(), test
.end() );
46 // copy the original reference sequence
47 Container
reference_copy(reference
);
48 std::transform(reference
.begin(), reference
.end(), reference
.begin(), DoubleValue());
50 // Do it again to push onto non-empty container
51 reference
.insert(reference
.end(), reference_copy
.begin(), reference_copy
.end());
53 boost::push_front(test
, boost::irange
<std::size_t>(0, n
* 2, 2));
55 BOOST_CHECK_EQUAL_COLLECTIONS( reference
.begin(), reference
.end(),
56 test
.begin(), test
.end() );
59 template< class Container
>
60 void test_push_front_impl()
62 test_push_front_impl
< Container
>(0);
63 test_push_front_impl
< Container
>(1);
64 test_push_front_impl
< Container
>(2);
65 test_push_front_impl
< Container
>(100);
68 void test_push_front()
70 test_push_front_impl
< std::vector
<std::size_t> >();
71 test_push_front_impl
< std::list
<std::size_t> >();
75 boost::unit_test::test_suite
*
76 init_unit_test_suite(int argc
, char* argv
[])
78 boost::unit_test::test_suite
* test
79 = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.push_front" );
81 test
->add( BOOST_TEST_CASE( &test_push_front
) );