mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
Stop using random_shuffle in the libc++ test suite. It's going to be removed in c++17. Use shuffle() instead. No change to libc++, just the tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294328 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user