aboutsummaryrefslogtreecommitdiff
path: root/test/std/algorithms/alg.sorting/alg.sort
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.sort
parent868847c6900e575417c03bced6e562b3af891318 (diff)
Notes
Diffstat (limited to 'test/std/algorithms/alg.sorting/alg.sort')
-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
7 files changed, 28 insertions, 7 deletions
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 1d4ca9925a86..d0b41cca3ca6 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 460ea4c08275..0ac2a86afce6 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 0d32ba898b8f..05a06a9c3357 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 a4fe1cc5e7ca..847a5829140a 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 689433f9e45b..6149a574b230 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 336fcd0b3dde..994d3a8c4a7c 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 49f7122cdb31..347711bf5e3a 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()));