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

@@ -15,10 +15,13 @@
// max_element(Iter first, Iter last);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -40,7 +43,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}

View File

@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -42,7 +45,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}

View File

@@ -15,10 +15,13 @@
// min_element(Iter first, Iter last);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -40,7 +43,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}

View File

@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -42,7 +45,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}

View File

@@ -15,10 +15,13 @@
// minmax_element(Iter first, Iter last);
#include <algorithm>
#include <random>
#include <cassert>
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -46,7 +49,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
@@ -66,7 +69,7 @@ test()
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
assert(base(p.first) == a);
assert(base(p.second) == a+N-1);

View File

@@ -16,11 +16,14 @@
#include <algorithm>
#include <functional>
#include <random>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
std::mt19937 randomness;
template <class Iter>
void
test(Iter first, Iter last)
@@ -50,7 +53,7 @@ test(int N)
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
test(Iter(a), Iter(a+N));
delete [] a;
}
@@ -70,7 +73,7 @@ test()
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
std::random_shuffle(a, a+N);
std::shuffle(a, a+N, randomness);
typedef std::greater<int> Compare;
Compare comp;
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);