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:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
|
@@ -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));
|
||||
|
@@ -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()));
|
||||
|
Reference in New Issue
Block a user