aboutsummaryrefslogtreecommitdiff
path: root/test/std/algorithms/alg.sorting/alg.nth.element
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/alg.sorting/alg.nth.element
parent868847c6900e575417c03bced6e562b3af891318 (diff)
Notes
Diffstat (limited to 'test/std/algorithms/alg.sorting/alg.nth.element')
-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
2 files changed, 8 insertions, 2 deletions
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 560bc902b482..b43d88fe0cc6 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 f2c962724f09..88249ed78d27 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