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 <mlib/tests/_pc_.h>
13
#include <mlib/range/adaptor/replaced.hpp>
14
#include <mlib/range/algorithm_ext.hpp>
16
#include <boost/assign.hpp>
27
template< class Container >
28
void replaced_test_impl( Container& c )
30
using namespace boost::adaptors;
32
const int value_to_replace = 1;
33
const int replacement_value = 0;
35
std::vector< int > test_result1;
36
boost::push_back(test_result1, c | replaced(value_to_replace, replacement_value));
38
std::vector< int > test_result2;
39
boost::push_back(test_result2, adaptors::replace(c, value_to_replace, replacement_value));
41
std::vector< int > reference( c.begin(), c.end() );
42
std::replace(reference.begin(), reference.end(), value_to_replace, replacement_value);
44
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
45
test_result1.begin(), test_result1.end() );
48
template< class Container >
49
void replaced_test_impl()
51
using namespace boost::assign;
56
replaced_test_impl(c);
60
replaced_test_impl(c);
63
c += 1,1,1,2,2,2,3,3,3,3,3,4,5,6,6,6,7,8,9;
64
replaced_test_impl(c);
69
replaced_test_impl< std::vector< int > >();
70
replaced_test_impl< std::list< int > >();
71
replaced_test_impl< std::set< int > >();
72
replaced_test_impl< std::multiset< int > >();
77
BOOST_AUTO_TEST_CASE( test_range_replaced_test )
79
boost::replaced_test();