]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/algorithm_ext_test/copy_n.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/copy_n.hpp>
13 #include <boost/test/test_tools.hpp>
14 #include <boost/test/unit_test.hpp>
16 #include <boost/range/iterator.hpp>
23 template< class Container
>
24 void test_copy_n_impl()
26 std::vector
<std::size_t> source
;
27 for (std::size_t i
= 0; i
< 10; ++i
)
30 for (std::size_t k
= 0; k
< 10; ++k
)
32 std::vector
<std::size_t> reference
;
33 for (std::size_t j
= 0; j
< k
; ++j
)
34 reference
.push_back(j
);
37 boost::copy_n(source
, k
, std::back_inserter(test
));
39 BOOST_CHECK_EQUAL_COLLECTIONS( reference
.begin(), reference
.end(),
40 test
.begin(), test
.end() );
46 test_copy_n_impl
< std::vector
<std::size_t> >();
47 test_copy_n_impl
< std::list
<std::size_t> >();
51 boost::unit_test::test_suite
*
52 init_unit_test_suite(int argc
, char* argv
[])
54 boost::unit_test::test_suite
* test
55 = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.copy_n" );
57 test
->add( BOOST_TEST_CASE( &test_copy_n
) );