summaryrefslogtreecommitdiff
path: root/test/std/algorithms
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
commit0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch)
tree051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test/std/algorithms
parent868847c6900e575417c03bced6e562b3af891318 (diff)
Notes
Diffstat (limited to 'test/std/algorithms')
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp1
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp1
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp6
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp6
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp4
-rw-r--r--test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp6
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp13
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp10
-rw-r--r--test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp11
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp8
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp8
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp7
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp7
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp7
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp7
-rw-r--r--test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp7
-rw-r--r--test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp5
-rw-r--r--test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp5
36 files changed, 160 insertions, 49 deletions
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index e24598a9bc127..e2abf7cce42e7 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// <algorithm>
+// REQUIRES: c++98 || c++03 || c++11 || c++14
// template<RandomAccessIterator Iter>
// requires ShuffleIterator<Iter>
diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
index c923d847f11e7..313b6bac402ea 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// <algorithm>
+// REQUIRES: c++98 || c++03 || c++11 || c++14
// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
// requires ShuffleIterator<Iter>
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
index de3f0a741045f..1cf2d9e845620 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
@@ -21,6 +21,8 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class InIter, class OutIter>
void
test()
@@ -28,8 +30,8 @@ test()
int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa];
- OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::equal_to<int>(), 2));
+ OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa),
+ OutIter(ib), equalToTwo);
assert(base(r) == ib + sa-3);
assert(ib[0] == 0);
assert(ib[1] == 1);
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
index 1eff3d39e20e8..f2ffece12e8b0 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
@@ -23,6 +23,8 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class InIter, class OutIter>
void
test()
@@ -30,8 +32,8 @@ test()
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa] = {0};
- OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::equal_to<int>(), 2), 5);
+ OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa),
+ OutIter(ib), equalToTwo, 5);
assert(base(r) == ib + sa);
assert(ib[0] == 0);
assert(ib[1] == 1);
diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
index 8d6ab04e14ddc..ebb2945d7c434 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
@@ -22,13 +22,15 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class Iter>
void
test()
{
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
- std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
+ std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5);
assert(ia[0] == 0);
assert(ia[1] == 1);
assert(ia[2] == 5);
diff --git a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
index 68556fd988175..6c5e621e4b20a 100644
--- a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
+++ b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
@@ -21,6 +21,8 @@
#include "test_iterators.h"
+int plusOne(int v) { return v + 1; }
+
template <class InIter, class OutIter>
void
test()
@@ -28,8 +30,8 @@ test()
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa] = {0};
- OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::plus<int>(), 1));
+ OutIter r = std::transform(InIter(ia), InIter(ia+sa),
+ OutIter(ib), plusOne);
assert(base(r) == ib + sa);
assert(ib[0] == 1);
assert(ib[1] == 2);
diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
index 025bc06a618da..0a05c6f659ca3 100644
--- a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
@@ -20,17 +20,24 @@
#include "test_iterators.h"
+struct eq {
+ eq (int val) : v(val) {}
+ bool operator () (int v2) const { return v == v2; }
+ int v;
+ };
+
+
int main()
{
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia + sa),
- std::bind2nd(std::equal_to<int>(),2)) == 3);
+ eq(2)) == 3);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia + sa),
- std::bind2nd(std::equal_to<int>(),7)) == 0);
+ eq(7)) == 0);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia),
- std::bind2nd(std::equal_to<int>(),2)) == 0);
+ eq(2)) == 0);
}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
index bde6ff389d0cd..c942d2e38a58c 100644
--- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
@@ -20,16 +20,22 @@
#include "test_iterators.h"
+struct eq {
+ eq (int val) : v(val) {}
+ bool operator () (int v2) const { return v == v2; }
+ int v;
+ };
+
int main()
{
int ia[] = {0, 1, 2, 3, 4, 5};
const unsigned s = sizeof(ia)/sizeof(ia[0]);
input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::equal_to<int>(), 3));
+ eq(3));
assert(*r == 3);
r = std::find_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::equal_to<int>(), 10));
+ eq(10));
assert(r == input_iterator<const int*>(ia+s));
}
diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
index 661e643f07d14..e68344b4b259e 100644
--- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
+++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
@@ -20,16 +20,23 @@
#include "test_iterators.h"
+struct ne {
+ ne (int val) : v(val) {}
+ bool operator () (int v2) const { return v != v2; }
+ int v;
+ };
+
+
int main()
{
int ia[] = {0, 1, 2, 3, 4, 5};
const unsigned s = sizeof(ia)/sizeof(ia[0]);
input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::not_equal_to<int>(), 3));
+ ne(3));
assert(*r == 3);
r = std::find_if_not(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::not_equal_to<int>(), 10));
+ ne(10));
assert(r == input_iterator<const int*>(ia+s));
}
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
index 9da9356b0be1d..082cad5f2d08e 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
@@ -15,14 +15,17 @@
// make_heap(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N);
assert(std::is_heap(ia, ia+N));
delete [] ia;
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
index 9d0545f0d9c50..01183d16c927e 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -17,6 +17,7 @@
#include <algorithm>
#include <functional>
#include <memory>
+#include <random>
#include <cassert>
#include "test_macros.h"
@@ -29,6 +30,7 @@ struct indirect_less
{return *x < *y;}
};
+std::mt19937 randomness;
void test(int N)
{
@@ -36,7 +38,7 @@ void test(int N)
{
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, std::greater<int>());
assert(std::is_heap(ia, ia+N, std::greater<int>()));
}
@@ -64,7 +66,7 @@ void test(int N)
// Random
{
binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, std::ref(pred));
assert(pred.count() <= 3u*N);
assert(std::is_heap(ia, ia+N, pred));
@@ -90,7 +92,7 @@ int main()
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
for (int i = 0; i < N; ++i)
ia[i].reset(new int(i));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, indirect_less());
assert(std::is_heap(ia, ia+N, indirect_less()));
delete [] ia;
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
index 252fc758cb1f8..8ba0f7194062c 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
@@ -15,14 +15,17 @@
// pop_heap(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N);
for (int i = N; i > 0; --i)
{
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
index 0bfad61961ed4..8e7931f7ea5d8 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
@@ -16,10 +16,12 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
+
struct indirect_less
{
template <class P>
@@ -29,12 +31,14 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, std::greater<int>());
for (int i = N; i > 0; --i)
{
@@ -55,7 +59,7 @@ int main()
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
for (int i = 0; i < N; ++i)
ia[i].reset(new int(i));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, indirect_less());
for (int i = N; i > 0; --i)
{
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
index d82896d6a916a..38d7a425d82b0 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
@@ -16,14 +16,17 @@
// push_heap(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
for (int i = 0; i <= N; ++i)
{
std::push_heap(ia, ia+i);
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
index 5d2985cc07fa6..38d09ceda6e2f 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
@@ -17,6 +17,7 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -30,12 +31,14 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
for (int i = 0; i <= N; ++i)
{
std::push_heap(ia, ia+i, std::greater<int>());
@@ -54,7 +57,7 @@ int main()
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
for (int i = 0; i < N; ++i)
ia[i].reset(new int(i));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
for (int i = 0; i <= N; ++i)
{
std::push_heap(ia, ia+i, indirect_less());
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
index c6eaa8ccec865..003138099f5a1 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
@@ -15,14 +15,17 @@
// sort_heap(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N);
std::sort_heap(ia, ia+N);
assert(std::is_sorted(ia, ia+N));
diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
index 1c072c5a12ca0..c0a05e4209b35 100644
--- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -29,12 +30,14 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
void test(int N)
{
int* ia = new int [N];
for (int i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, std::greater<int>());
std::sort_heap(ia, ia+N, std::greater<int>());
assert(std::is_sorted(ia, ia+N, std::greater<int>()));
@@ -56,7 +59,7 @@ int main()
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
for (int i = 0; i < N; ++i)
ia[i].reset(new int(i));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::make_heap(ia, ia+N, indirect_less());
std::sort_heap(ia, ia+N, indirect_less());
assert(std::is_sorted(ia, ia+N, indirect_less()));
diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
index 33a42a2f62a10..683b07d32089e 100644
--- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
@@ -16,6 +16,7 @@
// inplace_merge(Iter first, Iter middle, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
@@ -42,6 +43,8 @@ struct S {
};
#endif
+std::mt19937 randomness;
+
template <class Iter>
void
test_one(unsigned N, unsigned M)
@@ -51,7 +54,7 @@ test_one(unsigned N, unsigned M)
value_type* ia = new value_type[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::sort(ia, ia+M);
std::sort(ia+M, ia+N);
std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N));
diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
index fd9e5f13c26a4..3d8902ec22715 100644
--- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -17,6 +17,7 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_macros.h"
@@ -58,6 +59,8 @@ struct S {
#include "test_iterators.h"
#include "counting_predicates.hpp"
+std::mt19937 randomness;
+
template <class Iter>
void
test_one(unsigned N, unsigned M)
@@ -67,7 +70,7 @@ test_one(unsigned N, unsigned M)
value_type* ia = new value_type[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::sort(ia, ia+M, std::greater<value_type>());
std::sort(ia+M, ia+N, std::greater<value_type>());
binary_counting_predicate<std::greater<value_type>, value_type, value_type> pred((std::greater<value_type>()));
@@ -130,7 +133,7 @@ int main()
std::unique_ptr<int>* ia = new std::unique_ptr<int>[N];
for (int i = 0; i < N; ++i)
ia[i].reset(new int(i));
- std::random_shuffle(ia, ia+N);
+ std::shuffle(ia, ia+N, randomness);
std::sort(ia, ia+M, indirect_less());
std::sort(ia+M, ia+N, indirect_less());
std::inplace_merge(ia, ia+M, ia+N, indirect_less());
diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
index 2a20cac0b79b0..777461023e7d3 100644
--- a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
@@ -19,10 +19,13 @@
// merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class InIter1, class InIter2, class OutIter>
void
test()
@@ -53,7 +56,7 @@ test()
int* ic = new int[2*N];
for (unsigned i = 0; i < 2*N; ++i)
ic[i] = i;
- std::random_shuffle(ic, ic+2*N);
+ std::shuffle(ic, ic+2*N, randomness);
std::copy(ic, ic+N, ia);
std::copy(ic+N, ic+2*N, ib);
std::sort(ia, ia+N);
diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
index 152c552381b97..3daaeebbeae94 100644
--- a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
@@ -22,11 +22,14 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_iterators.h"
#include "counting_predicates.hpp"
+std::mt19937 randomness;
+
template <class InIter1, class InIter2, class OutIter>
void
test()
@@ -61,7 +64,7 @@ test()
int* ic = new int[2*N];
for (unsigned i = 0; i < 2*N; ++i)
ic[i] = i;
- std::random_shuffle(ic, ic+2*N);
+ std::shuffle(ic, ic+2*N, randomness);
std::copy(ic, ic+N, ia);
std::copy(ic+N, ic+2*N, ib);
std::sort(ia, ia+N, std::greater<int>());
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
index e9cd086ab13d7..471b08cc6e1f1 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
@@ -15,10 +15,13 @@
// max_element(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -40,7 +43,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
index e60e156455f31..95c7dee2cdb7c 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -42,7 +45,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
index c41884220857e..7cd41eaeae46e 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
@@ -15,10 +15,13 @@
// min_element(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -40,7 +43,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
index c4c6e31eb6dd7..402d57dae69e8 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -42,7 +45,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
index c2805a656137f..acede6ff7b56c 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
@@ -15,10 +15,13 @@
// minmax_element(Iter first, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -46,7 +49,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
@@ -66,7 +69,7 @@ test()
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
assert(base(p.first) == a);
assert(base(p.second) == a+N-1);
diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
index 7840638f742c9..ff83d7e55d3da 100644
--- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test(Iter first, Iter last)
@@ -50,7 +53,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
@@ -70,7 +73,7 @@ test()
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
- std::random_shuffle(a, a+N);
+ std::shuffle(a, a+N, randomness);
typedef std::greater<int> Compare;
Compare comp;
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
index 560bc902b4828..b43d88fe0cc6e 100644
--- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
@@ -16,8 +16,11 @@
// nth_element(Iter first, Iter nth, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void
test_one(int N, int M)
{
@@ -26,7 +29,7 @@ test_one(int N, int M)
int* array = new int[N];
for (int i = 0; i < N; ++i)
array[i] = i;
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::nth_element(array, array+M, array+N);
assert(array[M] == M);
std::nth_element(array, array+N, array+N); // begin, end, end
diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
index f2c962724f09f..88249ed78d278 100644
--- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
@@ -18,6 +18,7 @@
#include <algorithm>
#include <functional>
#include <vector>
+#include <random>
#include <cassert>
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -32,6 +33,8 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
void
test_one(int N, int M)
{
@@ -40,7 +43,7 @@ test_one(int N, int M)
int* array = new int[N];
for (int i = 0; i < N; ++i)
array[i] = i;
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::nth_element(array, array+M, array+N, std::greater<int>());
assert(array[M] == N-M-1);
std::nth_element(array, array+N, array+N, std::greater<int>()); // begin, end, end
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
index 1d4ca9925a86c..d0b41cca3ca69 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
@@ -18,10 +18,13 @@
// partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last);
#include <algorithm>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test_larger_sorts(int N, int M)
@@ -30,7 +33,7 @@ test_larger_sorts(int N, int M)
int* output = new int[M];
for (int i = 0; i < N; ++i)
input[i] = i;
- std::random_shuffle(input, input+N);
+ std::shuffle(input, input+N, randomness);
int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M);
int* e = output + std::min(N, M);
assert(r == e);
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
index 460ea4c082758..0ac2a86afce62 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
@@ -21,10 +21,13 @@
#include <algorithm>
#include <functional>
+#include <random>
#include <cassert>
#include "test_iterators.h"
+std::mt19937 randomness;
+
template <class Iter>
void
test_larger_sorts(int N, int M)
@@ -33,7 +36,7 @@ test_larger_sorts(int N, int M)
int* output = new int[M];
for (int i = 0; i < N; ++i)
input[i] = i;
- std::random_shuffle(input, input+N);
+ std::shuffle(input, input+N, randomness);
int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M,
std::greater<int>());
int* e = output + std::min(N, M);
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
index 0d32ba898b8f1..05a06a9c33577 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
@@ -16,8 +16,11 @@
// partial_sort(Iter first, Iter middle, Iter last);
#include <algorithm>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
void
test_larger_sorts(int N, int M)
{
@@ -26,7 +29,7 @@ test_larger_sorts(int N, int M)
int* array = new int[N];
for (int i = 0; i < N; ++i)
array[i] = i;
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::partial_sort(array, array+M, array+N);
for (int i = 0; i < M; ++i)
{
diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
index a4fe1cc5e7ca4..847a5829140a7 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
@@ -18,6 +18,7 @@
#include <algorithm>
#include <vector>
#include <functional>
+#include <random>
#include <cassert>
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -32,6 +33,8 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
void
test_larger_sorts(int N, int M)
{
@@ -40,7 +43,7 @@ test_larger_sorts(int N, int M)
int* array = new int[N];
for (int i = 0; i < N; ++i)
array[i] = i;
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::partial_sort(array, array+M, array+N, std::greater<int>());
for (int i = 0; i < M; ++i)
{
diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
index 689433f9e45ba..6149a574b2301 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
@@ -17,8 +17,11 @@
#include <algorithm>
#include <iterator>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
template <class RI>
void
test_sort_helper(RI f, RI l)
@@ -92,7 +95,7 @@ test_larger_sorts(int N, int M)
std::sort(array, array+N);
assert(std::is_sorted(array, array+N));
// test random pattern
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::sort(array, array+N);
assert(std::is_sorted(array, array+N));
// test sorted pattern
diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
index 336fcd0b3ddec..994d3a8c4a7c3 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
@@ -17,8 +17,11 @@
#include <algorithm>
#include <iterator>
+#include <random>
#include <cassert>
+std::mt19937 randomness;
+
template <class RI>
void
test_sort_helper(RI f, RI l)
@@ -92,7 +95,7 @@ test_larger_sorts(int N, int M)
std::stable_sort(array, array+N);
assert(std::is_sorted(array, array+N));
// test random pattern
- std::random_shuffle(array, array+N);
+ std::shuffle(array, array+N, randomness);
std::stable_sort(array, array+N);
assert(std::is_sorted(array, array+N));
// test sorted pattern
diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
index 49f7122cdb319..347711bf5e3a0 100644
--- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
+++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
@@ -18,6 +18,7 @@
#include <algorithm>
#include <functional>
#include <vector>
+#include <random>
#include <cassert>
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -32,6 +33,8 @@ struct indirect_less
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+std::mt19937 randomness;
+
struct first_only
{
bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
@@ -59,7 +62,7 @@ void test()
}
for (int i = 0; i < N - M; i += M)
{
- std::random_shuffle(v.begin() + i, v.begin() + i + M);
+ std::shuffle(v.begin() + i, v.begin() + i + M, randomness);
}
std::stable_sort(v.begin(), v.end(), first_only());
assert(std::is_sorted(v.begin(), v.end()));