Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<RandomAccessIterator Iter>
// requires ShuffleIterator<Iter>
// void
// random_shuffle(Iter first, Iter last);
#include <algorithm>
#include <cassert>
int main()
{
int ia[] = {1, 2, 3, 4};
int ia1[] = {1, 4, 3, 2};
int ia2[] = {4, 1, 2, 3};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
std::random_shuffle(ia, ia+sa);
assert(std::equal(ia, ia+sa, ia1));
std::random_shuffle(ia, ia+sa);
assert(std::equal(ia, ia+sa, ia2));
}

View File

@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
// requires ShuffleIterator<Iter>
// && Convertible<Rand::result_type, Iter::difference_type>
// void
// random_shuffle(Iter first, Iter last, Rand&& rand);
#include <algorithm>
#include <cassert>
struct gen
{
int operator()(int n)
{
return n-1;
}
};
int main()
{
int ia[] = {1, 2, 3, 4};
int ia1[] = {4, 1, 2, 3};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
gen r;
std::random_shuffle(ia, ia+sa, r);
assert(std::equal(ia, ia+sa, ia1));
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class RandomAccessIterator, class UniformRandomNumberGenerator>
// void shuffle(RandomAccessIterator first, RandomAccessIterator last,
// UniformRandomNumberGenerator& g);
#include <algorithm>
#include <random>
#include <cassert>
int main()
{
int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int ia1[] = {2, 7, 1, 4, 3, 6, 5, 10, 9, 8};
int ia2[] = {1, 8, 3, 4, 6, 9, 5, 7, 2, 10};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
std::minstd_rand g;
std::shuffle(ia, ia+sa, g);
assert(std::equal(ia, ia+sa, ia1));
std::shuffle(ia, ia+sa, g);
assert(std::equal(ia, ia+sa, ia2));
}