summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/algorithms')
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp6
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp9
2 files changed, 12 insertions, 3 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
index 8da8dfee719..b54efb688de 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -31,6 +31,7 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include "test_iterators.h"
+#include "counting_predicates.hpp"
template <class Iter>
void
@@ -43,12 +44,14 @@ test_one(unsigned N, unsigned M)
std::random_shuffle(ia, ia+N);
std::sort(ia, ia+M, std::greater<int>());
std::sort(ia+M, ia+N, std::greater<int>());
- std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::greater<int>());
+ binary_counting_predicate<std::greater<int>, int, int> pred((std::greater<int>()));
+ std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::ref(pred));
if(N > 0)
{
assert(ia[0] == N-1);
assert(ia[N-1] == 0);
assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+ assert(pred.count() <= (N-1));
}
delete [] ia;
}
@@ -79,6 +82,7 @@ test()
test_one<Iter>(3, 2);
test_one<Iter>(3, 3);
test<Iter>(4);
+ test<Iter>(20);
test<Iter>(100);
test<Iter>(1000);
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
index 69bcaf1198b..bd38d7de689 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
@@ -25,6 +25,7 @@
#include <cassert>
#include "test_iterators.h"
+#include "counting_predicates.hpp"
template <class InIter1, class InIter2, class OutIter>
void
@@ -41,12 +42,14 @@ test()
ib[i] = 2*i+1;
std::reverse(ia, ia+N);
std::reverse(ib, ib+N);
+ binary_counting_predicate<std::greater<int>, int, int> pred((std::greater<int>()));
OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
- InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+ InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
assert(base(r) == ic+2*N);
assert(ic[0] == 2*N-1);
assert(ic[2*N-1] == 0);
assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+ assert(pred.count() <= (N + N - 1));
delete [] ic;
delete [] ib;
delete [] ia;
@@ -63,12 +66,14 @@ test()
std::copy(ic+N, ic+2*N, ib);
std::sort(ia, ia+N, std::greater<int>());
std::sort(ib, ib+N, std::greater<int>());
+ binary_counting_predicate<std::greater<int>, int, int> pred((std::greater<int>()));
OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
- InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+ InIter2(ib), InIter2(ib+N), OutIter(ic), pred);
assert(base(r) == ic+2*N);
assert(ic[0] == 2*N-1);
assert(ic[2*N-1] == 0);
assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+ assert(pred.count() <= (N + N - 1));
delete [] ic;
delete [] ib;
delete [] ia;
OpenPOWER on IntegriCloud