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 #include <boost/range/algorithm/remove_copy.hpp>
13 #include <boost/test/test_tools.hpp>
14 #include <boost/test/unit_test.hpp>
16 #include <boost/assign.hpp>
26 template<typename Iterator
, typename Value
>
27 void test_append(Iterator target
, Value value
)
32 template< class Container
, class Value
>
33 void test_remove_copy_impl( const Container
& c
, Value to_remove
)
35 typedef typename
boost::range_value
<Container
>::type value_type
;
36 std::vector
<value_type
> reference
;
38 typedef BOOST_DEDUCED_TYPENAME
std::vector
<value_type
>::iterator
39 iterator_t BOOST_RANGE_UNUSED
;
42 std::remove_copy(c
.begin(), c
.end(),
43 std::back_inserter(reference
), to_remove
),
46 std::vector
<value_type
> test
;
48 boost::remove_copy(c
, std::back_inserter(test
), to_remove
),
51 BOOST_CHECK_EQUAL_COLLECTIONS( reference
.begin(), reference
.end(),
52 test
.begin(), test
.end() );
54 std::vector
<value_type
> test2
;
56 boost::remove_copy(boost::make_iterator_range(c
),
57 std::back_inserter(test2
), to_remove
),
60 BOOST_CHECK_EQUAL_COLLECTIONS( reference
.begin(), reference
.end(),
61 test2
.begin(), test2
.end() );
64 template< class Container
>
65 void test_remove_copy_impl()
67 using namespace boost::assign
;
70 test_remove_copy_impl(cont
, 0);
74 test_remove_copy_impl(cont
, 0);
75 test_remove_copy_impl(cont
, 1);
79 test_remove_copy_impl(cont
, 0);
80 test_remove_copy_impl(cont
, 1);
83 cont
+= 1,2,3,4,5,6,7,8,9;
84 test_remove_copy_impl(cont
, 1);
85 test_remove_copy_impl(cont
, 9);
86 test_remove_copy_impl(cont
, 4);
89 void test_remove_copy()
91 test_remove_copy_impl
< std::vector
<int> >();
92 test_remove_copy_impl
< std::list
<int> >();
93 test_remove_copy_impl
< std::deque
<int> >();
97 boost::unit_test::test_suite
*
98 init_unit_test_suite(int argc
, char* argv
[])
100 boost::unit_test::test_suite
* test
101 = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_copy" );
103 test
->add( BOOST_TEST_CASE( &test_remove_copy
) );