// Boost.Range library // // Copyright Neil Groves 2009. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // // For more information, see http://www.boost.org/libs/range/ // #include #include #include #include #include #include #include #include #include namespace boost { namespace { template< class Container > void test_copy_impl() { Container source; typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; std::vector target; target.resize(source.size()); typedef BOOST_DEDUCED_TYPENAME range_iterator< std::vector >::type iterator_t; iterator_t it = boost::copy(source, target.begin()); BOOST_CHECK( it == target.end() ); BOOST_CHECK_EQUAL_COLLECTIONS( target.begin(), target.end(), source.begin(), source.end() ); it = boost::copy(boost::make_iterator_range(source), target.begin()); BOOST_CHECK( it == target.end() ); BOOST_CHECK_EQUAL_COLLECTIONS(target.begin(), target.end(), source.begin(), source.end()); } void test_copy() { test_copy_impl< std::vector >(); test_copy_impl< std::list >(); test_copy_impl< std::set >(); test_copy_impl< std::multiset >(); } } } boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.copy" ); test->add( BOOST_TEST_CASE( &boost::test_copy ) ); return test; }