Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61648 - in trunk: boost/range/algorithm libs/range/test libs/range/test/algorithm_test
From: neil_at_[hidden]
Date: 2010-04-28 12:11:43


Author: neilgroves
Date: 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
New Revision: 61648
URL: http://svn.boost.org/trac/boost/changeset/61648

Log:
Boost.Range updated unit tests.
Added:
   trunk/libs/range/test/algorithm_test/copy_n.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/remove_copy.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/remove_copy_if.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/replace_copy.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/replace_copy_if.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/reverse_copy.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/rotate_copy.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/search_n.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/swap_ranges.cpp (contents, props changed)
   trunk/libs/range/test/algorithm_test/unique_copy.cpp (contents, props changed)
   trunk/libs/range/test/replace_copy.cpp (contents, props changed)
Text files modified:
   trunk/boost/range/algorithm/remove_copy_if.hpp | 4 ++--
   trunk/libs/range/test/Jamfile.v2 | 9 +++++++++
   trunk/libs/range/test/algorithm_test/for_each.cpp | 18 ++++++++++++------
   3 files changed, 23 insertions(+), 8 deletions(-)

Modified: trunk/boost/range/algorithm/remove_copy_if.hpp
==============================================================================
--- trunk/boost/range/algorithm/remove_copy_if.hpp (original)
+++ trunk/boost/range/algorithm/remove_copy_if.hpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -30,8 +30,8 @@
     inline OutputIterator
     remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred)
     {
- boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
- return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
+ BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+ return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
     }
 }
 

Modified: trunk/libs/range/test/Jamfile.v2
==============================================================================
--- trunk/libs/range/test/Jamfile.v2 (original)
+++ trunk/libs/range/test/Jamfile.v2 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -91,12 +91,19 @@
         [ range-test algorithm_test/prev_permutation ]
         [ range-test algorithm_test/random_shuffle ]
         [ range-test algorithm_test/remove ]
+ [ range-test algorithm_test/remove_copy ]
+ [ range-test algorithm_test/remove_copy_if ]
         [ range-test algorithm_test/remove_if ]
         [ range-test algorithm_test/replace ]
+ [ range-test algorithm_test/replace_copy ]
+ [ range-test algorithm_test/replace_copy_if ]
         [ range-test algorithm_test/replace_if ]
         [ range-test algorithm_test/reverse ]
+ [ range-test algorithm_test/reverse_copy ]
         [ range-test algorithm_test/rotate ]
+ [ range-test algorithm_test/rotate_copy ]
         [ range-test algorithm_test/search ]
+ [ range-test algorithm_test/search_n ]
         [ range-test algorithm_test/set_difference ]
         [ range-test algorithm_test/set_intersection ]
         [ range-test algorithm_test/set_symmetric_difference ]
@@ -104,8 +111,10 @@
         [ range-test algorithm_test/sort ]
         [ range-test algorithm_test/stable_partition ]
         [ range-test algorithm_test/stable_sort ]
+ [ range-test algorithm_test/swap_ranges ]
         [ range-test algorithm_test/transform ]
         [ range-test algorithm_test/unique ]
+ [ range-test algorithm_test/unique_copy ]
         [ range-test algorithm_test/upper_bound ]
         [ range-test algorithm_ext_test/copy_n ]
         [ range-test algorithm_ext_test/erase ]

Added: trunk/libs/range/test/algorithm_test/copy_n.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/copy_n.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,63 @@
+// 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 <boost/range/algorithm/copy_n.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/range/iterator.hpp>
+#include <algorithm>
+#include <list>
+#include <set>
+#include <vector>
+
+namespace
+{
+ template< class Container >
+ void test_copy_n_impl()
+ {
+ Container source;
+ typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t;
+
+ std::vector<value_t> target;
+ target.resize(source.size());
+
+ typedef BOOST_DEDUCED_TYPENAME range_iterator< std::vector<value_t> >::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()
+ );
+ }
+
+ void test_copy_n()
+ {
+ test_copy_n_impl< std::vector<int> >();
+ test_copy_n_impl< std::list<int> >();
+ test_copy_n_impl< std::set<int> >();
+ test_copy_n_impl< std::multiset<int> >();
+ }
+}
+
+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_n" );
+
+ test->add( BOOST_TEST_CASE( &::test_copy_n ) );
+
+ return test;
+}

Modified: trunk/libs/range/test/algorithm_test/for_each.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/for_each.cpp (original)
+++ trunk/libs/range/test/algorithm_test/for_each.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -26,6 +26,12 @@
 {
     namespace
     {
+ template< class Range >
+ unsigned int udistance(Range& rng)
+ {
+ return static_cast<unsigned int>(boost::distance(rng));
+ }
+
         template< class SinglePassRange >
         void test_for_each_impl( SinglePassRange rng )
         {
@@ -35,12 +41,12 @@
 
             // Test the mutable version
             fn_t result_fn = boost::for_each(rng, fn_t(rng));
- BOOST_CHECK_EQUAL( boost::distance(rng), result_fn.invocation_count() );
+ BOOST_CHECK_EQUAL( boost::udistance(rng), result_fn.invocation_count() );
 
             // Test the constant version
             const SinglePassRange& cref_rng = rng;
             result_fn = boost::for_each(cref_rng, fn_t(cref_rng));
- BOOST_CHECK_EQUAL( boost::distance(cref_rng), result_fn.invocation_count() );
+ BOOST_CHECK_EQUAL( boost::udistance(cref_rng), result_fn.invocation_count() );
         }
 
         template< class Container >
@@ -51,7 +57,7 @@
             // Test empty
             Container cont;
             test_for_each_impl(cont);
-
+
             // Test one element
             cont += 0;
             test_for_each_impl(cont);
@@ -63,7 +69,7 @@
 
         void test_for_each()
         {
- boost::array<int, 10> a = { 0,1,2,3,4,5,6,7,8,9 };
+ boost::array<int, 10> a = {{ 0,1,2,3,4,5,6,7,8,9 }};
             test_for_each_impl(a);
 
             test_for_each_t< std::vector<int> >();
@@ -79,8 +85,8 @@
 {
     boost::unit_test::test_suite* test
         = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.for_each" );
-
+
     test->add( BOOST_TEST_CASE( &boost::test_for_each ) );
-
+
     return test;
 }

Added: trunk/libs/range/test/algorithm_test/remove_copy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/remove_copy.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,98 @@
+// 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 <boost/range/algorithm/remove_copy.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<typename Iterator, typename Value>
+ void test_append(Iterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template< class Container, class Value >
+ void test_remove_copy_impl( const Container& c, Value to_remove )
+ {
+ typedef typename boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+
+ typedef BOOST_DEDUCED_TYPENAME std::vector<value_type>::iterator iterator_t;
+
+ test_append(
+ std::remove_copy(c.begin(), c.end(),
+ std::back_inserter(reference), to_remove),
+ to_remove);
+
+ std::vector<value_type> test;
+ test_append(
+ boost::remove_copy(c, std::back_inserter(test), to_remove),
+ to_remove);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+ }
+
+ template< class Container >
+ void test_remove_copy_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_remove_copy_impl(cont, 0);
+
+ cont.clear();
+ cont += 1;
+ test_remove_copy_impl(cont, 0);
+ test_remove_copy_impl(cont, 1);
+
+ cont.clear();
+ cont += 1,1,1,1,1;
+ test_remove_copy_impl(cont, 0);
+ test_remove_copy_impl(cont, 1);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_remove_copy_impl(cont, 1);
+ test_remove_copy_impl(cont, 9);
+ test_remove_copy_impl(cont, 4);
+ }
+
+ void test_remove_copy()
+ {
+ test_remove_copy_impl< std::vector<int> >();
+ test_remove_copy_impl< std::list<int> >();
+ test_remove_copy_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_copy" );
+
+ test->add( BOOST_TEST_CASE( &test_remove_copy ) );
+
+ return test;
+}
+

Added: trunk/libs/range/test/algorithm_test/remove_copy_if.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/remove_copy_if.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,103 @@
+// 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 <boost/range/algorithm/remove_copy_if.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template< class Iterator, class Value >
+ void test_append(Iterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template< class Container, class UnaryPredicate >
+ void test_remove_copy_if_impl( const Container& c, UnaryPredicate pred )
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<const Container>::type value_type;
+ std::vector<value_type> reference;
+
+ test_append(
+ std::remove_copy_if(c.begin(), c.end(), std::back_inserter(reference), pred),
+ value_type()
+ );
+
+ std::vector<value_type> test;
+ test_append(
+ boost::remove_copy_if(c, std::back_inserter(test), pred),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+ }
+
+ template< class Container >
+ void test_remove_copy_if_( const Container& c, int to_remove )
+ {
+ test_remove_copy_if_impl(c, boost::bind(std::equal_to<int>(), _1, to_remove));
+ test_remove_copy_if_impl(c, boost::bind(std::not_equal_to<int>(), _1, to_remove));
+ }
+
+ template< class Container >
+ void test_remove_copy_if_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_remove_copy_if_(cont, 0);
+
+ cont.clear();
+ cont += 1;
+ test_remove_copy_if_(cont, 0);
+ test_remove_copy_if_(cont, 1);
+
+ cont.clear();
+ cont += 1,1,1,1,1;
+ test_remove_copy_if_(cont, 0);
+ test_remove_copy_if_(cont, 1);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_remove_copy_if_(cont, 1);
+ test_remove_copy_if_(cont, 9);
+ test_remove_copy_if_(cont, 4);
+ }
+
+ inline void test_remove_copy_if()
+ {
+ test_remove_copy_if_impl< std::vector<int> >();
+ test_remove_copy_if_impl< std::list<int> >();
+ test_remove_copy_if_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_copy_if" );
+
+ test->add( BOOST_TEST_CASE( &test_remove_copy_if ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/replace_copy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/replace_copy.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,100 @@
+// 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 <boost/range/algorithm/replace_copy.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<typename Iterator, typename Value>
+ void test_append(Iterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template< class Container, class Value >
+ void test_replace_copy_impl( const Container& c, Value to_replace )
+ {
+ const Value replace_with = to_replace * 2;
+
+ typedef typename boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+
+ typedef BOOST_DEDUCED_TYPENAME std::vector<value_type>::iterator iterator_t;
+
+ test_append(
+ std::replace_copy(c.begin(), c.end(),
+ std::back_inserter(reference), to_replace, replace_with),
+ to_replace);
+
+ std::vector<value_type> test;
+ test_append(
+ boost::replace_copy(c, std::back_inserter(test), to_replace, replace_with),
+ to_replace);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+ }
+
+ template< class Container >
+ void test_replace_copy_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_replace_copy_impl(cont, 0);
+
+ cont.clear();
+ cont += 1;
+ test_replace_copy_impl(cont, 0);
+ test_replace_copy_impl(cont, 1);
+
+ cont.clear();
+ cont += 1,1,1,1,1;
+ test_replace_copy_impl(cont, 0);
+ test_replace_copy_impl(cont, 1);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_replace_copy_impl(cont, 1);
+ test_replace_copy_impl(cont, 9);
+ test_replace_copy_impl(cont, 4);
+ }
+
+ void test_replace_copy()
+ {
+ test_replace_copy_impl< std::vector<int> >();
+ test_replace_copy_impl< std::list<int> >();
+ test_replace_copy_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace_copy" );
+
+ test->add( BOOST_TEST_CASE( &test_replace_copy ) );
+
+ return test;
+}
+

Added: trunk/libs/range/test/algorithm_test/replace_copy_if.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/replace_copy_if.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,104 @@
+// 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 <boost/range/algorithm/replace_copy_if.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template< class Iterator, class Value >
+ void test_append(Iterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template< class Container, class UnaryPredicate >
+ void test_replace_copy_if_impl( const Container& c, UnaryPredicate pred )
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<const Container>::type value_type;
+ const value_type replace_with = value_type();
+ std::vector<value_type> reference;
+
+ test_append(
+ std::replace_copy_if(c.begin(), c.end(), std::back_inserter(reference), pred, replace_with),
+ value_type()
+ );
+
+ std::vector<value_type> test;
+ test_append(
+ boost::replace_copy_if(c, std::back_inserter(test), pred, replace_with),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+ }
+
+ template< class Container >
+ void test_replace_copy_if_( const Container& c, int to_replace )
+ {
+ test_replace_copy_if_impl(c, boost::bind(std::equal_to<int>(), _1, to_replace));
+ test_replace_copy_if_impl(c, boost::bind(std::not_equal_to<int>(), _1, to_replace));
+ }
+
+ template< class Container >
+ void test_replace_copy_if_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_replace_copy_if_(cont, 0);
+
+ cont.clear();
+ cont += 1;
+ test_replace_copy_if_(cont, 0);
+ test_replace_copy_if_(cont, 1);
+
+ cont.clear();
+ cont += 1,1,1,1,1;
+ test_replace_copy_if_(cont, 0);
+ test_replace_copy_if_(cont, 1);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_replace_copy_if_(cont, 1);
+ test_replace_copy_if_(cont, 9);
+ test_replace_copy_if_(cont, 4);
+ }
+
+ inline void test_replace_copy_if()
+ {
+ test_replace_copy_if_impl< std::vector<int> >();
+ test_replace_copy_if_impl< std::list<int> >();
+ test_replace_copy_if_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace_copy_if" );
+
+ test->add( BOOST_TEST_CASE( &test_replace_copy_if ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/reverse_copy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/reverse_copy.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,88 @@
+// 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 <boost/range/algorithm/reverse_copy.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<class OutputIterator, class Value>
+ void test_append(OutputIterator out, Value value)
+ {
+ *out++ = value;
+ }
+
+ template<class Container>
+ void test_reverse_copy_impl(Container& cont)
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+ std::vector<value_type> test;
+
+ test_append(
+ std::reverse_copy(cont.begin(), cont.end(), std::back_inserter(reference)),
+ value_type()
+ );
+
+ test_append(
+ boost::reverse_copy(cont, std::back_inserter(test)),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test.begin(), test.end()
+ );
+ }
+
+ template<class Container>
+ void test_reverse_copy_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_reverse_copy_impl(cont);
+
+ cont.clear();
+ cont += 1;
+ test_reverse_copy_impl(cont);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_reverse_copy_impl(cont);
+ }
+
+ void test_reverse_copy()
+ {
+ test_reverse_copy_impl< std::vector<int> >();
+ test_reverse_copy_impl< std::list<int> >();
+ test_reverse_copy_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.reverse_copy" );
+
+ test->add( BOOST_TEST_CASE( &::test_reverse_copy ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/rotate_copy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/rotate_copy.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,103 @@
+// 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 <boost/range/algorithm/rotate_copy.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<class OutputIterator, class Value>
+ void test_append(OutputIterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template<class Container, class Iterator>
+ void test_rotate_copy_impl(Container& cont, Iterator where_it)
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+ std::vector<value_type> test;
+
+ typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type iterator_t;
+
+ test_append(
+ std::rotate_copy(cont.begin(), where_it, cont.end(),
+ std::back_inserter(reference)),
+ value_type()
+ );
+
+ test_append(
+ boost::rotate_copy(cont, where_it, std::back_inserter(test)),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test.begin(), test.end()
+ );
+ }
+
+ template<class Container>
+ void test_rotate_copy_impl(Container& cont)
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type iterator_t;
+
+ iterator_t last = cont.end();
+ for (iterator_t it = cont.begin(); it != last; ++it)
+ {
+ test_rotate_copy_impl(cont, it);
+ }
+ }
+
+ template<class Container>
+ void test_rotate_copy_impl()
+ {
+ using namespace boost::assign;
+
+ Container cont;
+ test_rotate_copy_impl(cont);
+
+ cont.clear();
+ cont += 1;
+ test_rotate_copy_impl(cont);
+
+ cont.clear();
+ cont += 1,2,3,4,5,6,7,8,9;
+ test_rotate_copy_impl(cont);
+ }
+
+ void test_rotate_copy()
+ {
+ test_rotate_copy_impl< std::vector<int> >();
+ test_rotate_copy_impl< std::list<int> >();
+ test_rotate_copy_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.rotate_copy" );
+
+ test->add( BOOST_TEST_CASE( &test_rotate_copy ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/search_n.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/search_n.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,95 @@
+// 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 <boost/range/algorithm/search_n.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <algorithm>
+#include <list>
+#include <set>
+#include <vector>
+
+namespace
+{
+ template< class Container1, class Value >
+ void test_search_n_impl(Container1& cont1, Value value)
+ {
+ typedef BOOST_DEDUCED_TYPENAME Container1::const_iterator const_iterator1_t;
+ typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1_t;
+
+ const Container1& ccont1 = cont1;
+
+ for (std::size_t n = 0; n < cont1.size(); ++n)
+ {
+ iterator1_t it = boost::search_n(cont1, n, value);
+ iterator1_t it2 = boost::search_n(cont1, n, value);
+ const_iterator1_t cit = boost::search_n(ccont1, n, value);
+ const_iterator1_t cit2 = boost::search_n(ccont1, n, value);
+
+ BOOST_CHECK( it == std::search_n(cont1.begin(), cont1.end(), n, value) );
+ BOOST_CHECK( it2 == std::search_n(cont1.begin(), cont1.end(), n, value) );
+ BOOST_CHECK( cit == std::search_n(ccont1.begin(), ccont1.end(), n, value) );
+ BOOST_CHECK( cit2 == std::search_n(ccont1.begin(), ccont1.end(), n, value) );
+ }
+ }
+
+ template< class Container1, class Container2 >
+ void test_search_n_impl()
+ {
+ using namespace boost::assign;
+
+ Container1 cont1;
+
+ test_search_n_impl(cont1, 1);
+
+ cont1 += 1;
+ test_search_n_impl(cont1, 1);
+ test_search_n_impl(cont1, 0);
+
+ cont1.clear();
+ cont1 += 1,1;
+ test_search_n_impl(cont1, 1);
+ test_search_n_impl(cont1, 0);
+
+ cont1 += 1,1,1;
+ test_search_n_impl(cont1, 1);
+ test_search_n_impl(cont1, 0);
+
+ cont1.clear();
+ cont1 += 1,2,3,4,5,6,7,8,9;
+ test_search_n_impl(cont1, 1);
+ test_search_n_impl(cont1, 2);
+ test_search_n_impl(cont1, 5);
+ test_search_n_impl(cont1, 9);
+ }
+
+ void test_search_n()
+ {
+ test_search_n_impl< std::list<int>, std::list<int> >();
+ test_search_n_impl< std::vector<int>, std::vector<int> >();
+ test_search_n_impl< std::set<int>, std::set<int> >();
+ test_search_n_impl< std::list<int>, std::vector<int> >();
+ test_search_n_impl< std::vector<int>, std::list<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.search_n" );
+
+ test->add( BOOST_TEST_CASE( &test_search_n ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/swap_ranges.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/swap_ranges.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,95 @@
+// 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 <boost/range/algorithm/swap_ranges.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<class Container1, class Container2>
+ void test_swap_ranges_impl(const Container1& source1, const Container2& source2)
+ {
+ Container1 reference1(source1);
+ Container2 reference2(source2);
+ std::swap_ranges(reference1.begin(), reference1.end(), reference2.begin());
+
+ Container1 test1(source1);
+ Container2 test2(source2);
+ boost::swap_ranges(test1, test2);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference1.begin(), reference1.end(),
+ test1.begin(), test1.end()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference2.begin(), reference2.end(),
+ test2.begin(), test2.end()
+ );
+ }
+
+ template<class Container1, class Container2>
+ void test_swap_ranges_impl()
+ {
+ using namespace boost::assign;
+
+ Container1 c1;
+ Container2 c2;
+
+ test_swap_ranges_impl(c1, c2);
+
+ c1.clear();
+ c1 += 1;
+ c2.clear();
+ c2 += 2;
+ test_swap_ranges_impl(c1, c2);
+
+ c1.clear();
+ c1 += 1,2,3,4,5,6,7,8,9,10;
+ c2.clear();
+ c2 += 10,9,8,7,6,5,4,3,2,1;
+ test_swap_ranges_impl(c1, c2);
+ }
+
+ inline void test_swap_ranges()
+ {
+ test_swap_ranges_impl< std::vector<int>, std::vector<int> >();
+ test_swap_ranges_impl< std::vector<int>, std::list<int> >();
+ test_swap_ranges_impl< std::vector<int>, std::deque<int> >();
+ test_swap_ranges_impl< std::list<int>, std::vector<int> >();
+ test_swap_ranges_impl< std::list<int>, std::list<int> >();
+ test_swap_ranges_impl< std::list<int>, std::deque<int> >();
+ test_swap_ranges_impl< std::deque<int>, std::vector<int> >();
+ test_swap_ranges_impl< std::deque<int>, std::list<int> >();
+ test_swap_ranges_impl< std::deque<int>, std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.swap_ranges" );
+
+ test->add( BOOST_TEST_CASE( &test_swap_ranges ) );
+
+ return test;
+}

Added: trunk/libs/range/test/algorithm_test/unique_copy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/algorithm_test/unique_copy.cpp 2010-04-28 12:11:40 EDT (Wed, 28 Apr 2010)
@@ -0,0 +1,136 @@
+// 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 <boost/range/algorithm/unique_copy.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/assign.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <numeric>
+#include <deque>
+#include <vector>
+
+namespace
+{
+ template<class OutputIterator, class Value>
+ void test_append(OutputIterator target, Value value)
+ {
+ *target++ = value;
+ }
+
+ template<class Container>
+ void test_unique_copy_impl(Container& c)
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+ std::vector<value_type> test;
+
+ test_append(
+ std::unique_copy(c.begin(), c.end(), std::back_inserter(reference)),
+ value_type()
+ );
+
+ test_append(
+ boost::unique_copy(c, std::back_inserter(test)),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
+ test.begin(), test.end());
+ }
+
+ template<class Container, class Pred>
+ void test_unique_copy_impl(Container& c, Pred pred)
+ {
+ typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
+ std::vector<value_type> reference;
+ std::vector<value_type> test;
+
+ test_append(
+ std::unique_copy(c.begin(), c.end(), std::back_inserter(reference), pred),
+ value_type()
+ );
+
+ test_append(
+ boost::unique_copy(c, std::back_inserter(test), pred),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
+ test.begin(), test.end());
+ }
+
+ template<class Container, class Pred>
+ void test_unique_copy_driver(Pred pred)
+ {
+ using namespace boost::assign;
+
+ typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t;
+
+ Container cont;
+
+ test_unique_copy_impl(cont);
+ test_unique_copy_impl(cont, pred);
+
+ cont.clear();
+ cont += 1;
+
+ std::vector<value_t> temp(cont.begin(), cont.end());
+ std::sort(temp.begin(), temp.end());
+ cont.assign(temp.begin(), temp.end());
+ test_unique_copy_impl(cont);
+
+ std::sort(temp.begin(), temp.end(), pred);
+ cont.assign(temp.begin(), temp.end());
+ test_unique_copy_impl(cont, pred);
+
+ cont.clear();
+ cont += 1,2,2,2,2,3,4,5,6,7,8,9;
+
+ temp.assign(cont.begin(), cont.end());
+ std::sort(temp.begin(), temp.end());
+ cont.assign(temp.begin(), temp.end());
+ test_unique_copy_impl(cont);
+
+ std::sort(temp.begin(), temp.end(), pred);
+ cont.assign(temp.begin(), temp.end());
+ test_unique_copy_impl(cont, pred);
+ }
+
+ template<class Container>
+ void test_unique_copy_impl()
+ {
+ test_unique_copy_driver<Container>(std::less<int>());
+ test_unique_copy_driver<Container>(std::greater<int>());
+ }
+
+ void test_unique_copy()
+ {
+ test_unique_copy_impl< std::vector<int> >();
+ test_unique_copy_impl< std::list<int> >();
+ test_unique_copy_impl< std::deque<int> >();
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.unique_copy" );
+
+ test->add( BOOST_TEST_CASE( &test_unique_copy ) );
+
+ return test;
+}

Added: trunk/libs/range/test/replace_copy.cpp
==============================================================================


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk