|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63903 - trunk/libs/range/test/algorithm_test
From: neil_at_[hidden]
Date: 2010-07-11 20:12:55
Author: neilgroves
Date: 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
New Revision: 63903
URL: http://svn.boost.org/trac/boost/changeset/63903
Log:
[boost][range] - Improved handling of temporary ranges in range algorithms.
Text files modified:
trunk/libs/range/test/algorithm_test/adjacent_find.cpp | 8 +
trunk/libs/range/test/algorithm_test/binary_search.cpp | 4
trunk/libs/range/test/algorithm_test/copy.cpp | 7 +
trunk/libs/range/test/algorithm_test/copy_backward.cpp | 4
trunk/libs/range/test/algorithm_test/copy_n.cpp | 7 +
trunk/libs/range/test/algorithm_test/count.cpp | 40 +++--
trunk/libs/range/test/algorithm_test/count_if.cpp | 14 ++
trunk/libs/range/test/algorithm_test/equal.cpp | 40 ++++++
trunk/libs/range/test/algorithm_test/equal_range.cpp | 14 +
trunk/libs/range/test/algorithm_test/fill.cpp | 6
trunk/libs/range/test/algorithm_test/find.cpp | 14 +
trunk/libs/range/test/algorithm_test/find_end.cpp | 28 ++++
trunk/libs/range/test/algorithm_test/find_first_of.cpp | 32 ++++
trunk/libs/range/test/algorithm_test/find_if.cpp | 10 +
trunk/libs/range/test/algorithm_test/for_each.cpp | 3
trunk/libs/range/test/algorithm_test/generate.cpp | 6
trunk/libs/range/test/algorithm_test/heap.cpp | 23 +++
trunk/libs/range/test/algorithm_test/includes.cpp | 8 +
trunk/libs/range/test/algorithm_test/inplace_merge.cpp | 19 +++
trunk/libs/range/test/algorithm_test/lexicographical_compare.cpp | 14 +
trunk/libs/range/test/algorithm_test/lower_bound.cpp | 23 ++
trunk/libs/range/test/algorithm_test/max_element.cpp | 24 +++
trunk/libs/range/test/algorithm_test/merge.cpp | 80 +++++++++++++
trunk/libs/range/test/algorithm_test/min_element.cpp | 22 ++
trunk/libs/range/test/algorithm_test/mismatch.cpp | 245 ++++++++++++++++++++++++---------------
trunk/libs/range/test/algorithm_test/next_permutation.cpp | 21 +++
trunk/libs/range/test/algorithm_test/nth_element.cpp | 26 ++++
trunk/libs/range/test/algorithm_test/partial_sort.cpp | 22 +++
trunk/libs/range/test/algorithm_test/partition.cpp | 33 +++++
trunk/libs/range/test/algorithm_test/prev_permutation.cpp | 24 +++
trunk/libs/range/test/algorithm_test/random_shuffle.cpp | 19 +++
trunk/libs/range/test/algorithm_test/remove.cpp | 11 +
trunk/libs/range/test/algorithm_test/remove_copy.cpp | 9 +
trunk/libs/range/test/algorithm_test/remove_copy_if.cpp | 12 +
trunk/libs/range/test/algorithm_test/remove_if.cpp | 12 +
trunk/libs/range/test/algorithm_test/replace.cpp | 9 +
trunk/libs/range/test/algorithm_test/replace_copy.cpp | 12 +
trunk/libs/range/test/algorithm_test/replace_copy_if.cpp | 13 +
trunk/libs/range/test/algorithm_test/replace_if.cpp | 10 +
trunk/libs/range/test/algorithm_test/reverse.cpp | 12 +
trunk/libs/range/test/algorithm_test/reverse_copy.cpp | 15 +
trunk/libs/range/test/algorithm_test/rotate.cpp | 16 +
trunk/libs/range/test/algorithm_test/rotate_copy.cpp | 15 +
trunk/libs/range/test/algorithm_test/search.cpp | 16 ++
trunk/libs/range/test/algorithm_test/search_n.cpp | 10
trunk/libs/range/test/algorithm_test/set_difference.cpp | 44 +++++++
trunk/libs/range/test/algorithm_test/set_intersection.cpp | 44 +++++++
trunk/libs/range/test/algorithm_test/set_symmetric_difference.cpp | 44 +++++++
trunk/libs/range/test/algorithm_test/set_union.cpp | 40 ++++++
trunk/libs/range/test/algorithm_test/sort.cpp | 16 +
trunk/libs/range/test/algorithm_test/stable_partition.cpp | 28 ++++
trunk/libs/range/test/algorithm_test/stable_sort.cpp | 22 ++-
trunk/libs/range/test/algorithm_test/swap_ranges.cpp | 39 ++++-
trunk/libs/range/test/algorithm_test/transform.cpp | 34 ++++
trunk/libs/range/test/algorithm_test/unique.cpp | 26 +++
trunk/libs/range/test/algorithm_test/unique_copy.cpp | 22 +++
trunk/libs/range/test/algorithm_test/upper_bound.cpp | 25 +++
57 files changed, 1179 insertions(+), 217 deletions(-)
Modified: trunk/libs/range/test/algorithm_test/adjacent_find.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/adjacent_find.cpp (original)
+++ trunk/libs/range/test/algorithm_test/adjacent_find.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -9,7 +9,7 @@
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/range/algorithm/adjacent_find.hpp>
-
+#include <boost/range/iterator_range.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
@@ -38,14 +38,18 @@
BOOST_CHECK( boost::adjacent_find(cont) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cref_cont) == cref_cont.end() );
+ BOOST_CHECK( boost::adjacent_find(boost::make_iterator_range(cont)) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cont, pred) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cref_cont, pred) == cref_cont.end() );
+ BOOST_CHECK( boost::adjacent_find(boost::make_iterator_range(cont), pred) == cont.end() );
cont += 1;
BOOST_CHECK( boost::adjacent_find(cont) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cref_cont) == cref_cont.end() );
+ BOOST_CHECK( boost::adjacent_find(boost::make_iterator_range(cont)) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cont, pred) == cont.end() );
BOOST_CHECK( boost::adjacent_find(cref_cont, pred) == cref_cont.end() );
+ BOOST_CHECK( boost::adjacent_find(boost::make_iterator_range(cont), pred) == cont.end() );
cont += 2,3,4,5,5,5,6,7,8,9;
iterator_t it = boost::adjacent_find(cont);
@@ -57,6 +61,8 @@
{
BOOST_CHECK( *it == 5 );
}
+ BOOST_CHECK( it == boost::adjacent_find(boost::make_iterator_range(cont)) );
+ BOOST_CHECK( it_pred == boost::adjacent_find(boost::make_iterator_range(cont), pred) );
const_iterator_t cit = boost::adjacent_find(cref_cont);
const_iterator_t cit_pred = boost::adjacent_find(cref_cont, pred);
BOOST_CHECK( cit == cit_pred );
Modified: trunk/libs/range/test/algorithm_test/binary_search.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/binary_search.cpp (original)
+++ trunk/libs/range/test/algorithm_test/binary_search.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -37,6 +37,8 @@
BOOST_CHECK( reference_result == test_result );
+ BOOST_CHECK( test_result == boost::binary_search(boost::make_iterator_range(test), 5) );
+
BOOST_CHECK_EQUAL_COLLECTIONS(
reference.begin(), reference.end(),
test.begin(), test.end()
@@ -68,6 +70,8 @@
bool test_result = boost::binary_search(test, 5, pred);
+ BOOST_CHECK( test_result == boost::binary_search(boost::make_iterator_range(test), 5, pred) );
+
BOOST_CHECK( reference_result == test_result );
BOOST_CHECK_EQUAL_COLLECTIONS(
Modified: trunk/libs/range/test/algorithm_test/copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -42,6 +42,13 @@
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()
Modified: trunk/libs/range/test/algorithm_test/copy_backward.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/copy_backward.cpp (original)
+++ trunk/libs/range/test/algorithm_test/copy_backward.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -39,6 +39,10 @@
BOOST_CHECK( it == target.end() );
BOOST_CHECK_EQUAL_COLLECTIONS( target.begin(), target.end(),
source.rbegin(), source.rend() );
+
+ BOOST_CHECK( it == boost::copy_backward(boost::make_iterator_range(source), target.begin()) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( target.begin(), target.end(),
+ source.rbegin(), source.rend() );
}
void test_copy_backward()
Modified: trunk/libs/range/test/algorithm_test/copy_n.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/copy_n.cpp (original)
+++ trunk/libs/range/test/algorithm_test/copy_n.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -40,6 +40,13 @@
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_n()
Modified: trunk/libs/range/test/algorithm_test/count.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/count.cpp (original)
+++ trunk/libs/range/test/algorithm_test/count.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -31,28 +31,36 @@
Container cont;
const Container& cref_cont = cont;
- BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) );
- BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(boost::make_iterator_range(cont), 0u) );
cont += 1;
- BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) );
- BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(boost::make_iterator_range(cont), 0u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(boost::make_iterator_range(cont), 1u) );
cont += 2,3,4,5,6,7,8,9;
- BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) );
- BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(boost::make_iterator_range(cont), 0u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(boost::make_iterator_range(cont), 1u) );
cont += 2;
- BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) );
- BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) );
- BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) );
- BOOST_CHECK_EQUAL( 2u, boost::count(cont, 2) );
- BOOST_CHECK_EQUAL( 2u, boost::count(cref_cont, 2) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0u) );
+ BOOST_CHECK_EQUAL( 0u, boost::count(boost::make_iterator_range(cont), 0u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1u) );
+ BOOST_CHECK_EQUAL( 1u, boost::count(boost::make_iterator_range(cont), 1u) );
+ BOOST_CHECK_EQUAL( 2u, boost::count(cont, 2u) );
+ BOOST_CHECK_EQUAL( 2u, boost::count(cref_cont, 2u) );
+ BOOST_CHECK_EQUAL( 2u, boost::count(boost::make_iterator_range(cont), 2u) );
}
void test_count()
Modified: trunk/libs/range/test/algorithm_test/count_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/count_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/count_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -15,6 +15,7 @@
#include <boost/assign.hpp>
#include "../test_function/false_predicate.hpp"
+#include "../test_function/true_predicate.hpp"
#include "../test_function/equal_to_x.hpp"
#include <algorithm>
#include <list>
@@ -38,29 +39,42 @@
BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) );
+ BOOST_CHECK_EQUAL( 0u, boost::count_if(boost::make_iterator_range(cont), pred_t(0)) );
cont += 1;
BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) );
+ BOOST_CHECK_EQUAL( 0u, boost::count_if(boost::make_iterator_range(cont), pred_t(0)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) );
+ BOOST_CHECK_EQUAL( 1u, boost::count_if(boost::make_iterator_range(cont), pred_t(1)) );
cont += 2,3,4,5,6,7,8,9;
BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) );
+ BOOST_CHECK_EQUAL( 0u, boost::count_if(boost::make_iterator_range(cont), pred_t(0)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) );
+ BOOST_CHECK_EQUAL( 1u, boost::count_if(boost::make_iterator_range(cont), pred_t(1)) );
cont += 2;
BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) );
+ BOOST_CHECK_EQUAL( 0u, boost::count_if(boost::make_iterator_range(cont), pred_t(0)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) );
BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) );
+ BOOST_CHECK_EQUAL( 1u, boost::count_if(boost::make_iterator_range(cont), pred_t(1)) );
BOOST_CHECK_EQUAL( 2u, boost::count_if(cont, pred_t(2)) );
BOOST_CHECK_EQUAL( 2u, boost::count_if(cref_cont, pred_t(2)) );
+ BOOST_CHECK_EQUAL( 2u, boost::count_if(boost::make_iterator_range(cont), pred_t(2)) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, false_predicate()) );
BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, false_predicate()) );
+ BOOST_CHECK_EQUAL( 0u, boost::count_if(boost::make_iterator_range(cont), false_predicate()) );
+
+ BOOST_CHECK_EQUAL( cont.size(), boost::count_if(cont, true_predicate()) );
+ BOOST_CHECK_EQUAL( cont.size(), boost::count_if(cref_cont, true_predicate()) );
+ BOOST_CHECK_EQUAL( cont.size(), boost::count_if(boost::make_iterator_range(cont), true_predicate()) );
}
void test_count_if()
Modified: trunk/libs/range/test/algorithm_test/equal.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/equal.cpp (original)
+++ trunk/libs/range/test/algorithm_test/equal.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -38,30 +38,70 @@
Container2& cont2 = mcont2;
BOOST_CHECK( boost::equal(cont1, cont2) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2), std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::equal_to<int>()) );
BOOST_CHECK( boost::equal(cont1, cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
mcont1 += 1;
BOOST_CHECK( !boost::equal(cont1, cont2) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( !boost::equal(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(cont1, boost::make_iterator_range(cont2), std::equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::equal_to<int>()) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
mcont1.clear();
mcont2 += 1;
BOOST_CHECK( !boost::equal(cont1, cont2) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::equal_to<int>()) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
mcont1 += 1;
BOOST_CHECK( boost::equal(cont1, cont2) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2), std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::equal_to<int>()) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(cont1, boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
mcont1 += 2,3,4,5,6,7,8,9;
mcont2 += 2,3,4,5,6,7,8,9;
BOOST_CHECK( boost::equal(cont1, cont2) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), cont2, std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(cont1, boost::make_iterator_range(cont2), std::equal_to<int>()) );
+ BOOST_CHECK( boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::equal_to<int>()) );
BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), cont2, std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(cont1, boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
+ BOOST_CHECK( !boost::equal(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), std::not_equal_to<int>()) );
}
template< class Container1, class Container2 >
Modified: trunk/libs/range/test/algorithm_test/equal_range.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/equal_range.cpp (original)
+++ trunk/libs/range/test/algorithm_test/equal_range.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -70,8 +70,11 @@
pair_t test_result = boost::equal_range(test, 5);
- check_result(reference, reference_result,
- test, test_result);
+ check_result(reference, reference_result, test, test_result);
+
+ pair_t test_result2 = boost::equal_range(boost::make_iterator_range(test), 5);
+
+ check_result(reference, reference_result, test, test_result2);
}
template<class Container, class BinaryPredicate>
@@ -107,8 +110,11 @@
pair_t test_result = boost::equal_range(test, 5, BinaryPredicate());
- check_result(reference, reference_result,
- test, test_result);
+ check_result(reference, reference_result, test, test_result);
+
+ pair_t test_result2 = boost::equal_range(boost::make_iterator_range(test), 5, BinaryPredicate());
+
+ check_result(reference, reference_result, test, test_result2);
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/fill.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/fill.cpp (original)
+++ trunk/libs/range/test/algorithm_test/fill.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -36,6 +36,12 @@
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
target.begin(), target.end() );
+
+ Container target2(cont);
+ boost::fill(boost::make_iterator_range(target2), 1);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target2.begin(), target2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/find.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/find.cpp (original)
+++ trunk/libs/range/test/algorithm_test/find.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,7 +33,11 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find(cont, 3);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::find(cont, 3);
+ iter_t result2 = boost::find(boost::make_iterator_range(cont), 3);
+ BOOST_CHECK( result == result2 );
+ return result;
}
template<range_return_value return_type>
@@ -43,7 +47,11 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy&, Container& cont)
{
- return boost::find<return_type>(cont, 3);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find<return_type>(cont, 3);
+ result_t result2 = boost::find<return_type>(boost::make_iterator_range(cont), 3);
+ BOOST_CHECK( result == result2 );
+ return result;
}
};
@@ -90,6 +98,8 @@
std::vector<int> vi;
const std::vector<int>& cvi = vi;
std::vector<int>::const_iterator it = boost::find(vi, 0);
+ std::vector<int>::const_iterator it2 = boost::find(cvi, 0);
+ BOOST_CHECK( it == it2 );
}
}
}
Modified: trunk/libs/range/test/algorithm_test/find_end.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/find_end.cpp (original)
+++ trunk/libs/range/test/algorithm_test/find_end.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -41,7 +41,12 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find_end(cont, m_cont);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::find_end(cont, m_cont);
+ BOOST_CHECK( result == boost::find_end(boost::make_iterator_range(cont), m_cont) );
+ BOOST_CHECK( result == boost::find_end(cont, boost::make_iterator_range(m_cont)) );
+ BOOST_CHECK( result == boost::find_end(boost::make_iterator_range(cont), boost::make_iterator_range(m_cont)) );
+ return result;
}
template<range_return_value return_type>
@@ -51,7 +56,13 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::find_end<return_type>(cont, policy.cont());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find_end<return_type>(cont, policy.cont());
+ BOOST_CHECK( result == boost::find_end<return_type>(boost::make_iterator_range(cont), policy.cont()) );
+ BOOST_CHECK( result == boost::find_end<return_type>(cont, boost::make_iterator_range(policy.cont())) );
+ BOOST_CHECK( result == boost::find_end<return_type>(boost::make_iterator_range(cont),
+ boost::make_iterator_range(policy.cont())) );
+ return result;
}
};
@@ -84,7 +95,12 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find_end(cont, m_cont, m_pred);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t it = boost::find_end(cont, m_cont, m_pred);
+ BOOST_CHECK( it == boost::find_end(boost::make_iterator_range(cont), m_cont, m_pred) );
+ BOOST_CHECK( it == boost::find_end(cont, boost::make_iterator_range(m_cont), m_pred) );
+ BOOST_CHECK( it == boost::find_end(boost::make_iterator_range(cont), boost::make_iterator_range(m_cont), m_pred) );
+ return it;
}
template<range_return_value return_type>
@@ -94,6 +110,12 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find_end<return_type>(cont, policy.cont(), policy.pred());
+ BOOST_CHECK( result == boost::find_end<return_type>(boost::make_iterator_range(cont), policy.cont(), policy.pred()) );
+ BOOST_CHECK( result == boost::find_end<return_type>(cont, boost::make_iterator_range(policy.cont()), policy.pred()) );
+ BOOST_CHECK( result == boost::find_end<return_type>(boost::make_iterator_range(cont),
+ boost::make_iterator_range(policy.cont()), policy.pred()) );
return boost::find_end<return_type>(cont, policy.cont(), policy.pred());
}
};
Modified: trunk/libs/range/test/algorithm_test/find_first_of.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/find_first_of.cpp (original)
+++ trunk/libs/range/test/algorithm_test/find_first_of.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -41,7 +41,12 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find_first_of(cont, m_cont);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::find_first_of(cont, m_cont);
+ BOOST_CHECK( result == boost::find_first_of(boost::make_iterator_range(cont), m_cont) );
+ BOOST_CHECK( result == boost::find_first_of(cont, boost::make_iterator_range(m_cont)) );
+ BOOST_CHECK( result == boost::find_first_of(boost::make_iterator_range(cont), boost::make_iterator_range(m_cont)) );
+ return result;
}
template<range_return_value return_type>
@@ -51,7 +56,12 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::find_first_of<return_type>(cont, policy.cont());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find_first_of<return_type>(cont, policy.cont());
+ BOOST_CHECK( result == boost::find_first_of<return_type>(boost::make_iterator_range(cont), policy.cont()) );
+ BOOST_CHECK( result == boost::find_first_of<return_type>(cont, boost::make_iterator_range(policy.cont())) );
+ BOOST_CHECK( result == boost::find_first_of<return_type>(boost::make_iterator_range(cont), boost::make_iterator_range(policy.cont())) );
+ return result;
}
};
@@ -84,7 +94,12 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find_first_of(cont, m_cont, m_pred);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::find_first_of(cont, m_cont, m_pred);
+ BOOST_CHECK( result == boost::find_first_of(boost::make_iterator_range(cont), m_cont, m_pred) );
+ BOOST_CHECK( result == boost::find_first_of(cont, boost::make_iterator_range(m_cont), m_pred) );
+ BOOST_CHECK( result == boost::find_first_of(boost::make_iterator_range(cont), boost::make_iterator_range(m_cont), m_pred) );
+ return result;
}
template<range_return_value return_type>
@@ -94,7 +109,12 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::find_first_of<return_type>(cont, policy.cont(), policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find_first_of<return_type>(cont, policy.cont(), policy.pred());
+ BOOST_CHECK( result == boost::find_first_of<return_type>(boost::make_iterator_range(cont), policy.cont(), policy.pred()) );
+ BOOST_CHECK( result == boost::find_first_of<return_type>(cont, boost::make_iterator_range(policy.cont()), policy.pred()) );
+ BOOST_CHECK( result == boost::find_first_of<return_type>(boost::make_iterator_range(cont), boost::make_iterator_range(policy.cont()), policy.pred()) );
+ return result;
}
};
@@ -103,8 +123,8 @@
reference(Container& cont)
{
return std::find_first_of(cont.begin(), cont.end(),
- m_cont.begin(), m_cont.end(),
- m_pred);
+ m_cont.begin(), m_cont.end(),
+ m_pred);
}
private:
Modified: trunk/libs/range/test/algorithm_test/find_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/find_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/find_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -38,7 +38,10 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::find_if(cont, m_pred);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::find_if(cont, m_pred);
+ BOOST_CHECK( result == boost::find_if(boost::make_iterator_range(cont), m_pred) );
+ return result;
}
template<range_return_value return_type>
@@ -48,7 +51,10 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(find_if_test_policy& policy, Container& cont)
{
- return boost::find_if<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::find_if<return_type>(cont, policy.pred());
+ BOOST_CHECK( result == boost::find_if<return_type>(boost::make_iterator_range(cont), policy.pred()) );
+ return result;
}
};
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-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -42,6 +42,9 @@
// Test the mutable version
fn_t result_fn = boost::for_each(rng, fn_t(rng));
BOOST_CHECK_EQUAL( boost::udistance(rng), result_fn.invocation_count() );
+
+ fn_t result_fn2 = boost::for_each(boost::make_iterator_range(rng), fn_t(rng));
+ BOOST_CHECK_EQUAL( boost::udistance(rng), result_fn.invocation_count() );
// Test the constant version
const SinglePassRange& cref_rng = rng;
Modified: trunk/libs/range/test/algorithm_test/generate.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/generate.cpp (original)
+++ trunk/libs/range/test/algorithm_test/generate.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -49,6 +49,12 @@
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
test.begin(), test.end() );
+
+ Container test2(cont);
+ boost::generate(boost::make_iterator_range(test2), generator_fn());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/heap.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/heap.cpp (original)
+++ trunk/libs/range/test/algorithm_test/heap.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -41,28 +41,39 @@
reference += 1,2,3,4,5,6,7,8,9;
std::vector<int> test_cont(reference);
+ std::vector<int> test_cont2(reference);
std::make_heap(reference.begin(), reference.end());
boost::make_heap(test_cont);
check_equal(reference, test_cont);
+ boost::make_heap(boost::make_iterator_range(test_cont2));
+ check_equal(reference, test_cont2);
std::push_heap(reference.begin(), reference.end());
boost::push_heap(test_cont);
check_equal(reference, test_cont);
+ boost::push_heap(boost::make_iterator_range(test_cont2));
+ check_equal(reference, test_cont2);
std::make_heap(reference.begin(), reference.end());
boost::make_heap(test_cont);
+ boost::make_heap(boost::make_iterator_range(test_cont2));
std::sort_heap(reference.begin(), reference.end());
boost::sort_heap(test_cont);
check_equal(reference, test_cont);
+ boost::sort_heap(boost::make_iterator_range(test_cont2));
+ check_equal(reference, test_cont2);
std::make_heap(reference.begin(), reference.end());
boost::make_heap(test_cont);
+ boost::make_heap(boost::make_iterator_range(test_cont2));
std::pop_heap(reference.begin(), reference.end());
boost::pop_heap(test_cont);
check_equal(reference, test_cont);
+ boost::pop_heap(boost::make_iterator_range(test_cont2));
+ check_equal(reference, test_cont2);
}
template<class BinaryPredicate>
@@ -75,30 +86,42 @@
std::sort(reference.begin(), reference.end(), pred);
std::vector<int> test_cont(reference);
+ std::vector<int> test_cont2(reference);
std::make_heap(reference.begin(), reference.end(), pred);
boost::make_heap(test_cont, pred);
check_equal(reference, test_cont);
+ boost::make_heap(boost::make_iterator_range(test_cont2), pred);
+ check_equal(reference, test_cont2);
reference.push_back(5);
test_cont.push_back(5);
+ test_cont2.push_back(5);
std::push_heap(reference.begin(), reference.end(), pred);
boost::push_heap(test_cont, pred);
check_equal(reference, test_cont);
+ boost::push_heap(boost::make_iterator_range(test_cont2), pred);
+ check_equal(reference, test_cont2);
std::make_heap(reference.begin(), reference.end(), pred);
boost::make_heap(test_cont, pred);
+ boost::make_heap(boost::make_iterator_range(test_cont2), pred);
std::sort_heap(reference.begin(), reference.end(), pred);
boost::sort_heap(test_cont, pred);
check_equal(reference, test_cont);
+ boost::sort_heap(boost::make_iterator_range(test_cont2), pred);
+ check_equal(reference, test_cont2);
std::make_heap(reference.begin(), reference.end(), pred);
boost::make_heap(test_cont, pred);
+ boost::make_heap(boost::make_iterator_range(test_cont2), pred);
std::pop_heap(reference.begin(), reference.end(), pred);
boost::pop_heap(test_cont, pred);
check_equal(reference, test_cont);
+ boost::pop_heap(boost::make_iterator_range(test_cont2), pred);
+ check_equal(reference, test_cont2);
}
void test_heap()
Modified: trunk/libs/range/test/algorithm_test/includes.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/includes.cpp (original)
+++ trunk/libs/range/test/algorithm_test/includes.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -46,6 +46,10 @@
old_cont2.begin(), old_cont2.end(),
cont2.begin(), cont2.end()
);
+
+ BOOST_CHECK( test_result == boost::includes(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( test_result == boost::includes(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( test_result == boost::includes(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2)) );
}
template<class Container, class BinaryPredicate>
@@ -88,6 +92,10 @@
old_cont2.begin(), old_cont2.end(),
cont2.begin(), cont2.end()
);
+
+ BOOST_CHECK( test_result == boost::includes(boost::make_iterator_range(cont1), cont2, pred) );
+ BOOST_CHECK( test_result == boost::includes(cont1, boost::make_iterator_range(cont2), pred) );
+ BOOST_CHECK( test_result == boost::includes(boost::make_iterator_range(cont1), boost::make_iterator_range(cont2), pred) );
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/inplace_merge.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/inplace_merge.cpp (original)
+++ trunk/libs/range/test/algorithm_test/inplace_merge.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -35,6 +35,7 @@
cont2.begin(), cont2.end());
std::vector<value_t> test_target(reference_target);
+ std::vector<value_t> test_target2(reference_target);
std::inplace_merge(reference_target.begin(),
reference_target.begin() + cont1.size(),
@@ -47,6 +48,14 @@
reference_target.begin(), reference_target.end(),
test_target.begin(), test_target.end()
);
+
+ boost::inplace_merge(boost::make_iterator_range(test_target2),
+ test_target2.begin() + cont1.size());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target2.begin(), test_target2.end()
+ );
}
template<class Container, class BinaryPredicate>
@@ -75,6 +84,7 @@
cont2.begin(), cont2.end());
std::vector<value_t> test_target(reference_target);
+ std::vector<value_t> test_target2(reference_target);
std::inplace_merge(reference_target.begin(),
reference_target.begin() + cont1.size(),
@@ -88,6 +98,15 @@
reference_target.begin(), reference_target.end(),
test_target.begin(), test_target.end()
);
+
+ boost::inplace_merge(boost::make_iterator_range(test_target2),
+ test_target2.begin() + cont1.size(),
+ pred);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target2.begin(), test_target2.end()
+ );
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/lexicographical_compare.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/lexicographical_compare.cpp (original)
+++ trunk/libs/range/test/algorithm_test/lexicographical_compare.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -28,13 +28,16 @@
void test_lexicographical_compare_impl_nopred(ForwardRange1& rng1,
ForwardRange2& rng2)
{
- bool reference = std::lexicographical_compare(
+ const bool reference = std::lexicographical_compare(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
- bool test = boost::lexicographical_compare(rng1, rng2);
+ const bool test = boost::lexicographical_compare(rng1, rng2);
BOOST_CHECK( reference == test );
+ BOOST_CHECK( test == boost::lexicographical_compare(boost::make_iterator_range(rng1), rng2) );
+ BOOST_CHECK( test == boost::lexicographical_compare(rng1, boost::make_iterator_range(rng2)) );
+ BOOST_CHECK( test == boost::lexicographical_compare(boost::make_iterator_range(rng1), boost::make_iterator_range(rng2)) );
}
template<class ForwardRange1, class ForwardRange2,
@@ -43,14 +46,17 @@
ForwardRange2& rng2,
BinaryPredicate pred)
{
- bool reference = std::lexicographical_compare(
+ const bool reference = std::lexicographical_compare(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),
pred);
- bool test = boost::lexicographical_compare(rng1, rng2, pred);
+ const bool test = boost::lexicographical_compare(rng1, rng2, pred);
BOOST_CHECK( reference == test );
+ BOOST_CHECK( test == boost::lexicographical_compare(boost::make_iterator_range(rng1), rng2, pred) );
+ BOOST_CHECK( test == boost::lexicographical_compare(rng1, boost::make_iterator_range(rng2), pred) );
+ BOOST_CHECK( test == boost::lexicographical_compare(boost::make_iterator_range(rng1), boost::make_iterator_range(rng2), pred) );
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/lower_bound.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/lower_bound.cpp (original)
+++ trunk/libs/range/test/algorithm_test/lower_bound.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,7 +33,10 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::lower_bound(cont, 5);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::lower_bound(cont, 5);
+ BOOST_CHECK( result == boost::lower_bound(boost::make_iterator_range(cont), 5) );
+ return result;
}
template<range_return_value return_type>
@@ -43,7 +46,10 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy&, Container& cont)
{
- return boost::lower_bound<return_type>(cont, 5);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::lower_bound<return_type>(cont, 5);
+ BOOST_CHECK( result == boost::lower_bound<return_type>(boost::make_iterator_range(cont), 5) );
+ return result;
}
};
@@ -62,7 +68,11 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::lower_bound(cont, 5, m_pred);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::lower_bound(cont, 5, m_pred);
+ BOOST_CHECK( result == boost::lower_bound(
+ boost::make_iterator_range(cont), 5, m_pred) );
+ return result;
}
template< range_return_value return_type >
@@ -72,8 +82,11 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::lower_bound<return_type>(
- cont, 5, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::lower_bound<return_type>(cont, 5, policy.pred());
+ BOOST_CHECK( result == boost::lower_bound<return_type>(
+ boost::make_iterator_range(cont), 5, policy.pred()) );
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/max_element.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/max_element.cpp (original)
+++ trunk/libs/range/test/algorithm_test/max_element.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,7 +33,11 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::max_element(cont);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::max_element(cont);
+ BOOST_CHECK( result == boost::max_element(
+ boost::make_iterator_range(cont)) );
+ return result;
}
template<range_return_value return_type>
@@ -43,7 +47,11 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy&, Container& cont)
{
- return boost::max_element<return_type>(cont);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::max_element<return_type>(cont);
+ BOOST_CHECK( result == boost::max_element<return_type>(
+ boost::make_iterator_range(cont)) );
+ return result;
}
};
@@ -63,7 +71,11 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::max_element(cont, Pred());
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::max_element(cont, Pred());
+ BOOST_CHECK( result == boost::max_element(
+ boost::make_iterator_range(cont), Pred()) );
+ return result;
}
Pred pred() const { return Pred(); }
@@ -75,7 +87,11 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::max_element<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::max_element<return_type>(cont, policy.pred());
+ BOOST_CHECK( result == boost::max_element<return_type>(
+ boost::make_iterator_range(cont), policy.pred()) );
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/merge.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/merge.cpp (original)
+++ trunk/libs/range/test/algorithm_test/merge.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -51,6 +51,46 @@
reference_target.begin(), reference_target.end(),
test_target.begin(), test_target.end()
);
+
+ test_it = boost::merge(boost::make_iterator_range(cont1),
+ cont2, test_target.begin());
+
+ BOOST_CHECK_EQUAL(
+ std::distance<iterator_t>(reference_target.begin(), reference_it),
+ std::distance<iterator_t>(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
+
+ test_it = boost::merge(cont1, boost::make_iterator_range(cont2),
+ test_target.begin());
+
+ BOOST_CHECK_EQUAL(
+ std::distance<iterator_t>(reference_target.begin(), reference_it),
+ std::distance<iterator_t>(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
+
+ test_it = boost::merge(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_target.begin());
+
+ BOOST_CHECK_EQUAL(
+ std::distance<iterator_t>(reference_target.begin(), reference_it),
+ std::distance<iterator_t>(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
}
template<class Container, class BinaryPredicate>
@@ -95,6 +135,46 @@
reference_target.begin(), reference_target.end(),
test_target.begin(), test_target.end()
);
+
+ test_it = boost::merge(boost::make_iterator_range(cont1), cont2,
+ test_target.begin(), pred);
+
+ BOOST_CHECK_EQUAL(
+ std::distance(reference_target.begin(), reference_it),
+ std::distance(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
+
+ test_it = boost::merge(cont1, boost::make_iterator_range(cont2),
+ test_target.begin(), pred);
+
+ BOOST_CHECK_EQUAL(
+ std::distance(reference_target.begin(), reference_it),
+ std::distance(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
+
+ test_it = boost::merge(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_target.begin(), pred);
+
+ BOOST_CHECK_EQUAL(
+ std::distance(reference_target.begin(), reference_it),
+ std::distance(test_target.begin(), test_it)
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference_target.begin(), reference_target.end(),
+ test_target.begin(), test_target.end()
+ );
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/min_element.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/min_element.cpp (original)
+++ trunk/libs/range/test/algorithm_test/min_element.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,7 +33,10 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::min_element(cont);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::min_element(cont);
+ BOOST_CHECK( result == boost::min_element(boost::make_iterator_range(cont)) );
+ return result;
}
template< range_return_value return_type >
@@ -43,7 +46,10 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy&, Container& cont)
{
- return boost::min_element<return_type>(cont);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::min_element<return_type>(cont);
+ BOOST_CHECK( result == boost::min_element<return_type>(boost::make_iterator_range(cont)) );
+ return result;
}
};
@@ -63,7 +69,11 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::min_element(cont, Pred());
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::min_element(cont, Pred());
+ BOOST_CHECK( result == boost::min_element(
+ boost::make_iterator_range(cont), Pred()) );
+ return result;
}
Pred pred() const { return Pred(); }
@@ -75,7 +85,11 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::min_element<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ result_t result = boost::min_element<return_type>(cont, policy.pred());
+ BOOST_CHECK( result == boost::min_element<return_type>(
+ boost::make_iterator_range(cont), policy.pred()) );
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/mismatch.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/mismatch.cpp (original)
+++ trunk/libs/range/test/algorithm_test/mismatch.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -24,6 +24,130 @@
namespace
{
template< class Container1, class Container2 >
+ void eval_mismatch(Container1& cont1,
+ Container2& cont2,
+ BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type ref_it1,
+ BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type ref_it2
+ )
+ {
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type iter1_t;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type iter2_t;
+ typedef std::pair<iter1_t, iter2_t> result_pair_t;
+
+ result_pair_t result = boost::mismatch(cont1, cont2);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ cont2);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(cont1,
+ boost::make_iterator_range(cont2));
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2));
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+ }
+
+ template< class Container1, class Container2, class Pred >
+ void eval_mismatch(Container1& cont1,
+ Container2& cont2,
+ Pred pred,
+ BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type ref_it1,
+ BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type ref_it2
+ )
+ {
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type iter1_t;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type iter2_t;
+ typedef std::pair<iter1_t, iter2_t> result_pair_t;
+
+ result_pair_t result = boost::mismatch(cont1, cont2, pred);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ cont2, pred);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(cont1,
+ boost::make_iterator_range(cont2), pred);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ pred);
+ BOOST_CHECK( result.first == ref_it1 );
+ BOOST_CHECK( result.second == ref_it2 );
+ }
+
+ template< class Container1, class Container2 >
+ void eval_mismatch(Container1& cont1,
+ Container2& cont2,
+ const int ref1,
+ const int ref2)
+ {
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type iter1_t;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type iter2_t;
+ typedef std::pair<iter1_t, iter2_t> result_pair_t;
+
+ result_pair_t result = boost::mismatch(cont1, cont2);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1), cont2);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(cont1, boost::make_iterator_range(cont2));
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2));
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+ }
+
+ template< class Container1, class Container2, class Pred >
+ void eval_mismatch(Container1& cont1,
+ Container2& cont2,
+ Pred pred,
+ const int ref1,
+ const int ref2)
+ {
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container1>::type iter1_t;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container2>::type iter2_t;
+ typedef std::pair<iter1_t, iter2_t> result_pair_t;
+
+ result_pair_t result = boost::mismatch(cont1, cont2, pred);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ cont2, pred);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(cont1, boost::make_iterator_range(cont2),
+ pred);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+
+ result = boost::mismatch(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ pred);
+ BOOST_CHECK_EQUAL( ref1, *result.first );
+ BOOST_CHECK_EQUAL( ref2, *result.second );
+ }
+
+ template< class Container1, class Container2 >
void test_mismatch_impl()
{
using namespace boost::assign;
@@ -46,107 +170,42 @@
typedef std::pair<iterator1_t, const_iterator2_t> pair_mcit_t;
typedef std::pair<const_iterator1_t, const_iterator2_t> pair_ccit_t;
- pair_mmit_t pair_mmit = boost::mismatch(cont1, cont2);
- BOOST_CHECK( pair_mmit.first == cont1.end() );
- BOOST_CHECK( pair_mmit.second == cont2.end() );
- pair_mmit = boost::mismatch(cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mmit.first == cont1.end() );
- BOOST_CHECK( pair_mmit.second == cont2.end() );
-
- pair_cmit_t pair_cmit = boost::mismatch(cref_cont1, cont2);
- BOOST_CHECK( pair_cmit.first == cref_cont1.end() );
- BOOST_CHECK( pair_cmit.second == cont2.end() );
- pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_cmit.first == cref_cont1.end() );
- BOOST_CHECK( pair_cmit.second == cont2.end() );
-
- pair_mcit_t pair_mcit = boost::mismatch(cont1, cref_cont2);
- BOOST_CHECK( pair_mcit.first == cont1.end() );
- BOOST_CHECK( pair_mcit.second == cref_cont2.end() );
- pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mcit.first == cont1.end() );
- BOOST_CHECK( pair_mcit.second == cref_cont2.end() );
-
- pair_ccit_t pair_ccit = boost::mismatch(cref_cont1, cref_cont2);
- BOOST_CHECK( pair_ccit.first == cref_cont1.end() );
- BOOST_CHECK( pair_ccit.second == cref_cont2.end() );
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_ccit.first == cref_cont1.end() );
- BOOST_CHECK( pair_ccit.second == cref_cont2.end() );
+ eval_mismatch(cont1, cont2, cont1.end(), cont2.end());
+ eval_mismatch(cont1, cont2, std::equal_to<int>(), cont1.end(), cont2.end());
+ eval_mismatch(cref_cont1, cont2, cref_cont1.end(), cont2.end());
+ eval_mismatch(cref_cont1, cont2, std::equal_to<int>(), cref_cont1.end(), cont2.end());
+ eval_mismatch(cont1, cref_cont2, cont1.end(), cref_cont2.end());
+ eval_mismatch(cont1, cref_cont2, std::equal_to<int>(), cont1.end(), cref_cont2.end());
+ eval_mismatch(cref_cont1, cref_cont2, cref_cont1.end(), cref_cont2.end());
+ eval_mismatch(cref_cont1, cref_cont2, std::equal_to<int>(), cref_cont1.end(), cref_cont2.end());
cont1 += 1,2,3,4;
cont2 += 1,2,3,4;
- pair_mmit = boost::mismatch(cont1, cont2);
- BOOST_CHECK( pair_mmit.first == cont1.end() );
- BOOST_CHECK( pair_mmit.second == cont2.end() );
- pair_mmit = boost::mismatch(cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mmit.first == cont1.end() );
- BOOST_CHECK( pair_mmit.second == cont2.end() );
-
- pair_cmit = boost::mismatch(cref_cont1, cont2);
- BOOST_CHECK( pair_cmit.first == cref_cont1.end() );
- BOOST_CHECK( pair_cmit.second == cont2.end() );
- pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_cmit.first == cref_cont1.end() );
- BOOST_CHECK( pair_cmit.second == cont2.end() );
-
- pair_mcit = boost::mismatch(cont1, cref_cont2);
- BOOST_CHECK( pair_mcit.first == cont1.end() );
- BOOST_CHECK( pair_mcit.second == cref_cont2.end() );
- pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mcit.first == cont1.end() );
- BOOST_CHECK( pair_mcit.second == cref_cont2.end() );
-
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2);
- BOOST_CHECK( pair_ccit.first == cref_cont1.end() );
- BOOST_CHECK( pair_ccit.second == cref_cont2.end() );
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_ccit.first == cref_cont1.end() );
- BOOST_CHECK( pair_ccit.second == cref_cont2.end() );
+ eval_mismatch(cont1, cont2, cont1.end(), cont2.end());
+ eval_mismatch(cont1, cont2, std::equal_to<int>(), cont1.end(), cont2.end());
+ eval_mismatch(cref_cont1, cont2, cref_cont1.end(), cont2.end());
+ eval_mismatch(cref_cont1, cont2, std::equal_to<int>(), cref_cont1.end(), cont2.end());
+ eval_mismatch(cont1, cref_cont2, cont1.end(), cref_cont2.end());
+ eval_mismatch(cont1, cref_cont2, std::equal_to<int>(), cont1.end(), cref_cont2.end());
+ eval_mismatch(cref_cont1, cref_cont2, cref_cont1.end(), cref_cont2.end());
+ eval_mismatch(cref_cont1, cref_cont2, std::equal_to<int>(), cref_cont1.end(), cref_cont2.end());
cont1.clear();
cont2.clear();
cont1 += 1,2,3,4;
cont2 += 1,2,5,4;
- pair_mmit = boost::mismatch(cont1, cont2);
- BOOST_CHECK( pair_mmit.first != cont1.end() && *pair_mmit.first == 3 );
- BOOST_CHECK( pair_mmit.second != cont2.end() && *pair_mmit.second == 5 );
- pair_mmit = boost::mismatch(cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mmit.first != cont1.end() && *pair_mmit.first == 3 );
- BOOST_CHECK( pair_mmit.second != cont2.end() && *pair_mmit.second == 5 );
- pair_mmit = boost::mismatch(cont1, cont2, std::not_equal_to<int>());
- BOOST_CHECK( pair_mmit.first == cont1.begin() );
- BOOST_CHECK( pair_mmit.second == cont2.begin() );
-
- pair_cmit = boost::mismatch(cref_cont1, cont2);
- BOOST_CHECK( pair_cmit.first != cref_cont1.end() && *pair_cmit.first == 3 );
- BOOST_CHECK( pair_cmit.second != cont2.end() && *pair_cmit.second == 5 );
- pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to<int>());
- BOOST_CHECK( pair_cmit.first != cref_cont1.end() && *pair_cmit.first == 3 );
- BOOST_CHECK( pair_cmit.second != cont2.end() && *pair_cmit.second == 5 );
- pair_cmit = boost::mismatch(cref_cont1, cont2, std::not_equal_to<int>());
- BOOST_CHECK( pair_cmit.first == cref_cont1.begin() );
- BOOST_CHECK( pair_cmit.second == cont2.begin() );
-
- pair_mcit = boost::mismatch(cont1, cref_cont2);
- BOOST_CHECK( pair_mcit.first != cont1.end() && *pair_mcit.first == 3 );
- BOOST_CHECK( pair_mcit.second != cref_cont2.end() && *pair_mcit.second == 5 );
- pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_mcit.first != cont1.end() && *pair_mcit.first == 3 );
- BOOST_CHECK( pair_mcit.second != cref_cont2.end() && *pair_mcit.second == 5 );
- pair_mcit = boost::mismatch(cont1, cref_cont2, std::not_equal_to<int>());
- BOOST_CHECK( pair_mcit.first == cont1.begin() );
- BOOST_CHECK( pair_mcit.second == cref_cont2.begin() );
-
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2);
- BOOST_CHECK( pair_ccit.first != cref_cont1.end() && *pair_ccit.first == 3 );
- BOOST_CHECK( pair_ccit.second != cref_cont2.end() && *pair_ccit.second == 5 );
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to<int>());
- BOOST_CHECK( pair_ccit.first != cref_cont1.end() && *pair_ccit.first == 3 );
- BOOST_CHECK( pair_ccit.second != cref_cont2.end() && *pair_ccit.second == 5 );
- pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::not_equal_to<int>());
- BOOST_CHECK( pair_ccit.first == cref_cont1.begin() );
- BOOST_CHECK( pair_ccit.second == cref_cont2.begin() );
+ eval_mismatch(cont1, cont2, 3, 5);
+ eval_mismatch(cont1, cont2, std::equal_to<int>(), 3, 5);
+ eval_mismatch(cont1, cont2, std::not_equal_to<int>(), cont1.begin(), cont2.begin());
+ eval_mismatch(cref_cont1, cont2, 3, 5);
+ eval_mismatch(cref_cont1, cont2, std::equal_to<int>(), 3, 5);
+ eval_mismatch(cref_cont1, cont2, std::not_equal_to<int>(), cref_cont1.begin(), cont2.begin());
+ eval_mismatch(cont1, cref_cont2, 3, 5);
+ eval_mismatch(cont1, cref_cont2, std::equal_to<int>(), 3, 5);
+ eval_mismatch(cont1, cref_cont2, std::not_equal_to<int>(), cont1.begin(), cref_cont2.begin());
+ eval_mismatch(cref_cont1, cref_cont2, 3, 5);
+ eval_mismatch(cref_cont1, cref_cont2, std::equal_to<int>(), 3, 5);
+ eval_mismatch(cref_cont1, cref_cont2, std::not_equal_to<int>(), cref_cont1.begin(), cref_cont2.begin());
}
void test_mismatch()
Modified: trunk/libs/range/test/algorithm_test/next_permutation.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/next_permutation.cpp (original)
+++ trunk/libs/range/test/algorithm_test/next_permutation.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -29,8 +29,7 @@
const bool reference_ret
= std::next_permutation(reference.begin(), reference.end());
- const bool test_ret
- = boost::next_permutation(test);
+ const bool test_ret = boost::next_permutation(test);
BOOST_CHECK( reference_ret == test_ret );
@@ -38,6 +37,15 @@
reference.begin(), reference.end(),
test.begin(), test.end()
);
+
+ test = cont;
+
+ BOOST_CHECK( test_ret == boost::next_permutation(boost::make_iterator_range(test)) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test.begin(), test.end()
+ );
}
template<class Container, class BinaryPredicate>
@@ -60,6 +68,15 @@
reference.begin(), reference.end(),
test.begin(), test.end()
);
+
+ test = cont;
+
+ BOOST_CHECK( test_ret == boost::next_permutation(boost::make_iterator_range(test), pred) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test.begin(), test.end()
+ );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/nth_element.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/nth_element.cpp (original)
+++ trunk/libs/range/test/algorithm_test/nth_element.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -29,7 +29,21 @@
template<class Container, class Iterator>
void test_nth_element(Container& cont, Iterator mid)
{
+ const Container old_cont(cont);
+
boost::nth_element(cont, mid);
+
+ // Test the same operation on the container, for the
+ // case where a temporary is passed as the first
+ // argument.
+ Container cont2(old_cont);
+ const std::size_t index = std::distance(cont.begin(), mid);
+ Iterator mid2(cont2.begin());
+ std::advance(mid2, index);
+ boost::nth_element(boost::make_iterator_range(cont2), mid2);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
}
template<class Container, class Iterator>
@@ -45,7 +59,19 @@
template<class Container, class Iterator>
void test_nth_element(Container& cont, Iterator mid)
{
+ const Container old_cont(cont);
+
boost::nth_element(cont, mid, BinaryPredicate());
+
+ Container cont2(old_cont);
+ const std::size_t index = std::distance(cont.begin(), mid);
+ Iterator mid2(cont2.begin());
+ std::advance(mid2, index);
+ boost::nth_element(boost::make_iterator_range(cont2), mid2,
+ BinaryPredicate());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
}
template<class Container, class Iterator>
Modified: trunk/libs/range/test/algorithm_test/partial_sort.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/partial_sort.cpp (original)
+++ trunk/libs/range/test/algorithm_test/partial_sort.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -31,7 +31,18 @@
template<class Container, class Iterator>
void test_partial_sort(Container& cont, Iterator mid)
{
+ const Container old_cont(cont);
+
boost::partial_sort(cont, mid);
+
+ const std::size_t index = std::distance(cont.begin(), mid);
+ Container cont2(old_cont);
+ Iterator mid2(cont2.begin());
+ std::advance(mid2, index);
+ boost::partial_sort(cont2, mid2);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
}
template<class Container, class Iterator>
@@ -47,7 +58,18 @@
template<class Container, class Iterator>
void test_partial_sort(Container& cont, Iterator mid)
{
+ const Container old_cont(cont);
+
boost::partial_sort(cont, mid, BinaryPredicate());
+
+ const std::size_t index = std::distance(cont.begin(), mid);
+ Container cont2(old_cont);
+ Iterator mid2(cont2.begin());
+ std::advance(mid2, index);
+ boost::partial_sort(cont2, mid2, BinaryPredicate());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
}
template<class Container, class Iterator>
Modified: trunk/libs/range/test/algorithm_test/partition.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/partition.cpp (original)
+++ trunk/libs/range/test/algorithm_test/partition.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -41,7 +41,21 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::partition(cont, UnaryPredicate());
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+
+ const Container old_cont(cont);
+ Container cont2(old_cont);
+ iter_t result = boost::partition(cont, UnaryPredicate());
+
+ iter_t temp_result = boost::partition(cont2, UnaryPredicate());
+ cont2 = old_cont;
+ BOOST_CHECK( temp_result == boost::partition(
+ boost::make_iterator_range(cont2), UnaryPredicate()) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
+
+ return result;
}
UnaryPredicate pred() const { return UnaryPredicate(); }
@@ -53,7 +67,22 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::partition<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+
+ const Container old_cont(cont);
+ Container cont2(old_cont);
+ result_t result = boost::partition<return_type>(cont, policy.pred());
+
+ result_t temp_result = boost::partition<return_type>(
+ cont2, policy.pred());
+ cont2 = old_cont;
+ BOOST_CHECK( temp_result == boost::partition<return_type>(
+ boost::make_iterator_range(cont2), policy.pred()) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
+
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/prev_permutation.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/prev_permutation.cpp (original)
+++ trunk/libs/range/test/algorithm_test/prev_permutation.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -25,12 +25,12 @@
{
Container reference(cont);
Container test(cont);
+ Container test2(cont);
const bool reference_ret
= std::prev_permutation(reference.begin(), reference.end());
- const bool test_ret
- = boost::prev_permutation(test);
+ const bool test_ret = boost::prev_permutation(test);
BOOST_CHECK( reference_ret == test_ret );
@@ -38,6 +38,14 @@
reference.begin(), reference.end(),
test.begin(), test.end()
);
+
+ BOOST_CHECK( test_ret == boost::prev_permutation(
+ boost::make_iterator_range(test2)) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test2.begin(), test2.end()
+ );
}
template<class Container, class BinaryPredicate>
@@ -46,13 +54,13 @@
{
Container reference(cont);
Container test(cont);
+ Container test2(cont);
const bool reference_ret
= std::prev_permutation(reference.begin(), reference.end(),
pred);
- const bool test_ret
- = boost::prev_permutation(test, pred);
+ const bool test_ret = boost::prev_permutation(test, pred);
BOOST_CHECK( reference_ret == test_ret );
@@ -60,6 +68,14 @@
reference.begin(), reference.end(),
test.begin(), test.end()
);
+
+ BOOST_CHECK( test_ret == boost::prev_permutation(
+ boost::make_iterator_range(test2), pred) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ reference.begin(), reference.end(),
+ test2.begin(), test2.end()
+ );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/random_shuffle.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/random_shuffle.cpp (original)
+++ trunk/libs/range/test/algorithm_test/random_shuffle.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -110,6 +110,14 @@
{
shuffled = true;
}
+
+ // Verify that the shuffle can be performed on a
+ // temporary range
+ Container test2(cont);
+ boost::random_shuffle(boost::make_iterator_range(test2));
+ ok = test_shuffle_result(cont, test2);
+ if (!ok)
+ break;
}
}
@@ -124,6 +132,17 @@
{
BOOST_CHECK( gen.invocation_count() > 0 );
}
+
+ // Test that random shuffle works when
+ // passed a temporary range
+ RandomGenerator gen2;
+ Container cont2(old_cont);
+ boost::random_shuffle(boost::make_iterator_range(cont2), gen2);
+ test_shuffle_result(cont2, old_cont);
+ if (cont2.size() > 2)
+ {
+ BOOST_CHECK( gen2.invocation_count() > 0 );
+ }
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/remove.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/remove.cpp (original)
+++ trunk/libs/range/test/algorithm_test/remove.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -43,7 +43,16 @@
std::distance(reference.begin(), reference_it) );
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- test.begin(), test.end() );
+ test.begin(), test.end() );
+
+ Container test2(c);
+ iterator_t test_it2 = boost::remove(test2, to_remove);
+
+ BOOST_CHECK_EQUAL( std::distance(test2.begin(), test_it2),
+ std::distance(reference.begin(), reference_it) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/remove_copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/remove_copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/remove_copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -50,6 +50,15 @@
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
test.begin(), test.end() );
+
+ std::vector<value_type> test2;
+ test_append(
+ boost::remove_copy(boost::make_iterator_range(c),
+ std::back_inserter(test2), to_remove),
+ to_remove);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/remove_copy_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/remove_copy_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/remove_copy_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -48,7 +48,17 @@
);
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- test.begin(), test.end() );
+ test.begin(), test.end() );
+
+ std::vector<value_type> test2;
+ test_append(
+ boost::remove_copy_if(boost::make_iterator_range(c),
+ std::back_inserter(test2), pred),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/remove_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/remove_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/remove_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -43,7 +43,17 @@
std::distance(reference.begin(), reference_it) );
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- test.begin(), test.end() );
+ test.begin(), test.end() );
+
+ Container test2(c);
+ iterator_t test_it2 = boost::remove_if(
+ boost::make_iterator_range(test2), pred);
+
+ BOOST_CHECK_EQUAL( std::distance(test2.begin(), test_it2),
+ std::distance(reference.begin(), reference_it) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/replace.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/replace.cpp (original)
+++ trunk/libs/range/test/algorithm_test/replace.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -36,7 +36,14 @@
boost::replace(target, what, with_what);
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- target.begin(), target.end() );
+ target.begin(), target.end() );
+
+ std::vector<int> target2(cont.begin(), cont.end());
+ boost::replace(boost::make_iterator_range(target2), what,
+ with_what);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target2.begin(), target2.end() );
}
Modified: trunk/libs/range/test/algorithm_test/replace_copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/replace_copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/replace_copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -51,7 +51,17 @@
to_replace);
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- test.begin(), test.end() );
+ test.begin(), test.end() );
+
+ std::vector<value_type> test2;
+ test_append(
+ boost::replace_copy(boost::make_iterator_range(c),
+ std::back_inserter(test2), to_replace,
+ replace_with),
+ to_replace);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/replace_copy_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/replace_copy_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/replace_copy_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -49,7 +49,18 @@
);
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- test.begin(), test.end() );
+ test.begin(), test.end() );
+
+ std::vector<value_type> test2;
+ test_append(
+ boost::replace_copy_if(boost::make_iterator_range(c),
+ std::back_inserter(test2), pred,
+ replace_with),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/replace_if.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/replace_if.cpp (original)
+++ trunk/libs/range/test/algorithm_test/replace_if.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -40,8 +40,14 @@
boost::replace_if(target, boost::bind(pred, _1, what), with_what);
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- target.begin(), target.end() );
-
+ target.begin(), target.end() );
+
+ std::vector<int> target2(cont.begin(), cont.end());
+ boost::replace_if(boost::make_iterator_range(target2),
+ boost::bind(pred, _1, what), with_what);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target2.begin(), target2.end() );
}
template< class Container >
Modified: trunk/libs/range/test/algorithm_test/reverse.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/reverse.cpp (original)
+++ trunk/libs/range/test/algorithm_test/reverse.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -29,14 +29,16 @@
{
Container reference(cont);
Container test(cont);
+ Container test2(cont);
boost::reverse(test);
std::reverse(reference.begin(), reference.end());
-
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ boost::reverse(boost::make_iterator_range(test2));
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/reverse_copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/reverse_copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/reverse_copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -45,10 +45,19 @@
value_type()
);
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ test.clear();
+
+ test_append(
+ boost::reverse_copy(boost::make_iterator_range(cont),
+ std::back_inserter(test)),
+ value_type()
);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/rotate.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/rotate.cpp (original)
+++ trunk/libs/range/test/algorithm_test/rotate.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -42,10 +42,18 @@
boost::rotate(test, test_where_it);
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ test = cont;
+ test_where_it = test.begin();
+ std::advance(test_where_it,
+ std::distance(cont.begin(), where_it));
+
+ boost::rotate(boost::make_iterator_range(test), test_where_it);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/rotate_copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/rotate_copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/rotate_copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -48,10 +48,19 @@
value_type()
);
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ test.clear();
+
+ test_append(
+ boost::rotate_copy(boost::make_iterator_range(cont), where_it,
+ std::back_inserter(test)),
+ value_type()
);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/search.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/search.cpp (original)
+++ trunk/libs/range/test/algorithm_test/search.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,9 +33,25 @@
const Container2& ccont2 = cont2;
iterator1_t it = boost::search(cont1, cont2);
+ BOOST_CHECK( it == boost::search(boost::make_iterator_range(cont1), cont2) );
+ BOOST_CHECK( it == boost::search(cont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( it == boost::search(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2)) );
iterator1_t it2 = boost::search(cont1, ccont2);
+ BOOST_CHECK( it2 == boost::search(boost::make_iterator_range(cont1), ccont2) );
+ BOOST_CHECK( it2 == boost::search(cont1, boost::make_iterator_range(ccont2)) );
+ BOOST_CHECK( it2 == boost::search(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(ccont2)) );
const_iterator1_t cit = boost::search(ccont1, cont2);
+ BOOST_CHECK( cit == boost::search(boost::make_iterator_range(ccont1), cont2) );
+ BOOST_CHECK( cit == boost::search(ccont1, boost::make_iterator_range(cont2)) );
+ BOOST_CHECK( cit == boost::search(boost::make_iterator_range(ccont1),
+ boost::make_iterator_range(cont2)) );
const_iterator1_t cit2 = boost::search(ccont1, ccont2);
+ BOOST_CHECK( cit2 == boost::search(boost::make_iterator_range(ccont1), ccont2) );
+ BOOST_CHECK( cit2 == boost::search(ccont1, boost::make_iterator_range(ccont2)) );
+ BOOST_CHECK( cit2 == boost::search(boost::make_iterator_range(ccont1),
+ boost::make_iterator_range(ccont2)) );
BOOST_CHECK( it == std::search(cont1.begin(), cont1.end(), cont2.begin(), cont2.end()) );
BOOST_CHECK( it2 == std::search(cont1.begin(), cont1.end(), ccont2.begin(), ccont2.end()) );
Modified: trunk/libs/range/test/algorithm_test/search_n.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/search_n.cpp (original)
+++ trunk/libs/range/test/algorithm_test/search_n.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -32,14 +32,12 @@
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 == boost::search_n(boost::make_iterator_range(cont1), 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) );
+
+ const_iterator1_t cit = boost::search_n(ccont1, n, value);
+ BOOST_CHECK( cit == boost::search_n(boost::make_iterator_range(ccont1), 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) );
}
}
Modified: trunk/libs/range/test/algorithm_test/set_difference.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/set_difference.cpp (original)
+++ trunk/libs/range/test/algorithm_test/set_difference.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -62,6 +62,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_difference(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_difference(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_difference(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container, class BinaryPredicate>
@@ -100,6 +122,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_difference(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_difference(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_difference(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/set_intersection.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/set_intersection.cpp (original)
+++ trunk/libs/range/test/algorithm_test/set_intersection.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -62,6 +62,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container, class BinaryPredicate>
@@ -100,6 +122,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_intersection(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/set_symmetric_difference.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/set_symmetric_difference.cpp (original)
+++ trunk/libs/range/test/algorithm_test/set_symmetric_difference.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -63,6 +63,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container, class BinaryPredicate>
@@ -102,6 +124,28 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ boost::make_iterator_range(cont1), cont2,
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ cont1, boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_symmetric_difference(
+ boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/set_union.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/set_union.cpp (original)
+++ trunk/libs/range/test/algorithm_test/set_union.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -62,6 +62,26 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_union(boost::make_iterator_range(cont1),
+ cont2, test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_union(cont1,
+ boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_union(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin());
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container, class BinaryPredicate>
@@ -100,6 +120,26 @@
check_result(reference, reference_result,
test_cont, test_result);
+
+ test_result = boost::set_union(boost::make_iterator_range(cont1),
+ cont2, test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_union(cont1,
+ boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
+
+ test_result = boost::set_union(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ test_cont.begin(), pred);
+
+ check_result(reference, reference_result,
+ test_cont, test_result);
}
template<class Container1, class Container2>
Modified: trunk/libs/range/test/algorithm_test/sort.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/sort.cpp (original)
+++ trunk/libs/range/test/algorithm_test/sort.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,10 +33,13 @@
boost::sort(test);
std::sort(reference.begin(), reference.end());
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ Container test2(cont);
+ boost::sort(boost::make_iterator_range(test2));
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template<class Container, class BinaryPredicate>
@@ -52,6 +55,11 @@
reference.begin(), reference.end(),
test.begin(), test.end()
);
+
+ Container test2(cont);
+ boost::sort(boost::make_iterator_range(test2), pred);
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test2.begin(), test2.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/stable_partition.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/stable_partition.cpp (original)
+++ trunk/libs/range/test/algorithm_test/stable_partition.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -41,7 +41,21 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::stable_partition(cont, UnaryPredicate());
+ Container cont2(cont);
+
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::stable_partition(cont, UnaryPredicate());
+
+ iter_t temp_result = boost::stable_partition(
+ boost::make_iterator_range(cont2), UnaryPredicate());
+
+ BOOST_CHECK_EQUAL( std::distance(cont.begin(), result),
+ std::distance(cont2.begin(), temp_result) );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
+
+ return result;
}
UnaryPredicate pred() const { return UnaryPredicate(); }
@@ -53,7 +67,17 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::stable_partition<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+ Container cont2(cont);
+ result_t result = boost::stable_partition<return_type>(cont, policy.pred());
+
+ result_t result2 = boost::stable_partition<return_type>(
+ boost::make_iterator_range(cont2), policy.pred());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont2.begin(), cont2.end(),
+ cont.begin(), cont.end() );
+
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/stable_sort.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/stable_sort.cpp (original)
+++ trunk/libs/range/test/algorithm_test/stable_sort.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -33,10 +33,13 @@
boost::stable_sort(test);
std::stable_sort(reference.begin(), reference.end());
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ test = cont;
+ boost::stable_sort(boost::make_iterator_range(test));
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
}
template<class Container, class BinaryPredicate>
@@ -48,10 +51,13 @@
boost::stable_sort(test, pred);
std::stable_sort(reference.begin(), reference.end(), pred);
- BOOST_CHECK_EQUAL_COLLECTIONS(
- reference.begin(), reference.end(),
- test.begin(), test.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+
+ test = cont;
+ boost::stable_sort(boost::make_iterator_range(test), pred);
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
}
template<class Container>
Modified: trunk/libs/range/test/algorithm_test/swap_ranges.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/swap_ranges.cpp (original)
+++ trunk/libs/range/test/algorithm_test/swap_ranges.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -35,15 +35,36 @@
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()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference1.begin(), reference1.end(),
+ test1.begin(), test1.end() );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference2.begin(), reference2.end(),
+ test2.begin(), test2.end() );
+
+ test1 = source1;
+ test2 = source2;
+ boost::swap_ranges(boost::make_iterator_range(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() );
+
+ test1 = source1;
+ test2 = source2;
+ boost::swap_ranges(test1, boost::make_iterator_range(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() );
+
+ test1 = source1;
+ test2 = source2;
+ boost::swap_ranges(boost::make_iterator_range(test1),
+ boost::make_iterator_range(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>
Modified: trunk/libs/range/test/algorithm_test/transform.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/transform.cpp (original)
+++ trunk/libs/range/test/algorithm_test/transform.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -47,16 +47,23 @@
BOOST_CHECK( test_it == target.end() );
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- target.begin(), target.end() );
-
+ target.begin(), target.end() );
+
+ BOOST_CHECK( test_it == boost::transform(boost::make_iterator_range(cont), target.begin(), fn) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target.begin(), target.end() );
+
target.clear();
target.resize(ccont.size());
test_it = boost::transform(ccont, target.begin(), fn);
-
+
BOOST_CHECK( test_it == target.end() );
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- target.begin(), target.end() );
+ target.begin(), target.end() );
+ BOOST_CHECK( test_it == boost::transform(boost::make_iterator_range(ccont), target.begin(), fn) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target.begin(), target.end() );
}
template< class Container >
@@ -97,10 +104,25 @@
iterator_t test_it
= boost::transform(cont1, cont2, target.begin(), fn);
-
+
BOOST_CHECK( test_it == target.end() );
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
- target.begin(), target.end() );
+ target.begin(), target.end() );
+
+ BOOST_CHECK( test_it == boost::transform(boost::make_iterator_range(cont1), cont2, target.begin(), fn) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target.begin(), target.end() );
+
+ BOOST_CHECK( test_it == boost::transform(cont1, boost::make_iterator_range(cont2), target.begin(), fn) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target.begin(), target.end() );
+
+ BOOST_CHECK( test_it == boost::transform(boost::make_iterator_range(cont1),
+ boost::make_iterator_range(cont2),
+ target.begin(), fn) );
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ target.begin(), target.end() );
+
target.clear();
target.resize(ccont1.size());
Modified: trunk/libs/range/test/algorithm_test/unique.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/unique.cpp (original)
+++ trunk/libs/range/test/algorithm_test/unique.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -47,7 +47,18 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy&, Container& cont)
{
- return boost::unique<return_type>(cont);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+
+ Container cont2(cont);
+
+ result_t result = boost::unique<return_type>(cont);
+
+ boost::unique<return_type>(boost::make_iterator_range(cont2));
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
+
+ return result;
}
};
@@ -82,7 +93,18 @@
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::unique<return_type>(cont, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type result_t;
+
+ Container cont2(cont);
+
+ result_t result = boost::unique<return_type>(cont, policy.pred());
+
+ boost::unique<return_type>(boost::make_iterator_range(cont2), policy.pred());
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( cont.begin(), cont.end(),
+ cont2.begin(), cont2.end() );
+
+ return result;
}
};
Modified: trunk/libs/range/test/algorithm_test/unique_copy.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/unique_copy.cpp (original)
+++ trunk/libs/range/test/algorithm_test/unique_copy.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -49,6 +49,17 @@
BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
test.begin(), test.end());
+
+ test.clear();
+
+ test_append(
+ boost::unique_copy(boost::make_iterator_range(c),
+ std::back_inserter(test)),
+ value_type()
+ );
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
+ test.begin(), test.end());
}
template<class Container, class Pred>
@@ -70,6 +81,17 @@
BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
test.begin(), test.end());
+
+ test.clear();
+
+ test_append(
+ boost::unique_copy(boost::make_iterator_range(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>
Modified: trunk/libs/range/test/algorithm_test/upper_bound.cpp
==============================================================================
--- trunk/libs/range/test/algorithm_test/upper_bound.cpp (original)
+++ trunk/libs/range/test/algorithm_test/upper_bound.cpp 2010-07-11 20:12:49 EDT (Sun, 11 Jul 2010)
@@ -32,7 +32,10 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::upper_bound(cont, 5);
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::upper_bound(cont, 5);
+ BOOST_CHECK( result == boost::upper_bound(boost::make_iterator_range(cont), 5) );
+ return result;
}
template<range_return_value result_type>
@@ -42,7 +45,10 @@
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
operator()(Policy&, Container& cont)
{
- return boost::upper_bound<result_type>(cont, 5);
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type result_t;
+ result_t result = boost::upper_bound<result_type>(cont, 5);
+ BOOST_CHECK( result == boost::upper_bound<result_type>(boost::make_iterator_range(cont), 5) );
+ return result;
}
};
@@ -61,7 +67,10 @@
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
test_iter(Container& cont)
{
- return boost::upper_bound(cont, 5, BinaryPredicate());
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iter_t;
+ iter_t result = boost::upper_bound(cont, 5, BinaryPredicate());
+ BOOST_CHECK( result == boost::upper_bound(boost::make_iterator_range(cont), 5, BinaryPredicate()) );
+ return result;
}
template< range_return_value result_type>
@@ -71,8 +80,14 @@
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
operator()(Policy& policy, Container& cont)
{
- return boost::upper_bound<result_type>(
- cont, 5, policy.pred());
+ typedef BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type result_t;
+
+ result_t result = boost::upper_bound<result_type>(cont, 5, policy.pred());
+
+ BOOST_CHECK( result == boost::upper_bound<result_type>(
+ boost::make_iterator_range(cont), 5, policy.pred()) );
+
+ return result;
}
};
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