diff options
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.cpp | 5 | ||||
| -rw-r--r-- | test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp | 5 |
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 |
