diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
| commit | 0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch) | |
| tree | 051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test/std/algorithms/alg.sorting/alg.heap.operations | |
| parent | 868847c6900e575417c03bced6e562b3af891318 (diff) | |
Notes
Diffstat (limited to 'test/std/algorithms/alg.sorting/alg.heap.operations')
8 files changed, 37 insertions, 13 deletions
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 9da9356b0be1..082cad5f2d08 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 9d0545f0d9c5..01183d16c927 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 252fc758cb1f..8ba0f7194062 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 0bfad61961ed..8e7931f7ea5d 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 d82896d6a916..38d7a425d82b 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 5d2985cc07fa..38d09ceda6e2 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 c6eaa8ccec86..003138099f5a 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 1c072c5a12ca..c0a05e4209b3 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())); |
