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:
Marshall Clow
2017-02-07 18:41:25 +00:00
parent 542c6e8f9b
commit 426546ecec
29 changed files with 124 additions and 37 deletions

View File

@@ -16,6 +16,7 @@
// inplace_merge(Iter first, Iter middle, Iter last);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_iterators.h"
@@ -42,6 +43,8 @@ struct S {
};
#endif
std::mt19937 randomness;
template <class Iter>
void
test_one(unsigned N, unsigned M)
@@ -51,7 +54,7 @@ test_one(unsigned N, unsigned M)
value_type* ia = new value_type[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
std::random_shuffle(ia, ia+N);
std::shuffle(ia, ia+N, randomness);
std::sort(ia, ia+M);
std::sort(ia+M, ia+N);
std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N));

View File

@@ -17,6 +17,7 @@
#include <algorithm>
#include <functional>
#include <random>
#include <cassert>
#include "test_macros.h"
@@ -58,6 +59,8 @@ struct S {
#include "test_iterators.h"
#include "counting_predicates.hpp"
std::mt19937 randomness;
template <class Iter>
void
test_one(unsigned N, unsigned M)
@@ -67,7 +70,7 @@ test_one(unsigned N, unsigned M)
value_type* ia = new value_type[N];
for (unsigned i = 0; i < N; ++i)
ia[i] = i;
std::random_shuffle(ia, ia+N);
std::shuffle(ia, ia+N, randomness);
std::sort(ia, ia+M, std::greater<value_type>());
std::sort(ia+M, ia+N, std::greater<value_type>());
binary_counting_predicate<std::greater<value_type>, value_type, value_type> pred((std::greater<value_type>()));
@@ -130,7 +133,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::sort(ia, ia+M, indirect_less());
std::sort(ia+M, ia+N, indirect_less());
std::inplace_merge(ia, ia+M, ia+N, indirect_less());

View File

@@ -19,10 +19,13 @@
// merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_iterators.h"
std::mt19937 randomness;
template <class InIter1, class InIter2, class OutIter>
void
test()
@@ -53,7 +56,7 @@ test()
int* ic = new int[2*N];
for (unsigned i = 0; i < 2*N; ++i)
ic[i] = i;
std::random_shuffle(ic, ic+2*N);
std::shuffle(ic, ic+2*N, randomness);
std::copy(ic, ic+N, ia);
std::copy(ic+N, ic+2*N, ib);
std::sort(ia, ia+N);

View File

@@ -22,11 +22,14 @@
#include <algorithm>
#include <functional>
#include <random>
#include <cassert>
#include "test_iterators.h"
#include "counting_predicates.hpp"
std::mt19937 randomness;
template <class InIter1, class InIter2, class OutIter>
void
test()
@@ -61,7 +64,7 @@ test()
int* ic = new int[2*N];
for (unsigned i = 0; i < 2*N; ++i)
ic[i] = i;
std::random_shuffle(ic, ic+2*N);
std::shuffle(ic, ic+2*N, randomness);
std::copy(ic, ic+N, ia);
std::copy(ic+N, ic+2*N, ib);
std::sort(ia, ia+N, std::greater<int>());