summaryrefslogtreecommitdiffstats
path: root/libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-26 17:49:34 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-26 17:49:34 +0000
commitf9d540b0624ff755e1903a9a8a708d5ea8190386 (patch)
treef1fcffffa7b8ad195a60ecc05843f36d7c762b1a /libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
parenta19838e1076f361c3fde481c515f60a13a64b19f (diff)
downloadbcm5719-llvm-f9d540b0624ff755e1903a9a8a708d5ea8190386.tar.gz
bcm5719-llvm-f9d540b0624ff755e1903a9a8a708d5ea8190386.zip
Completed [alg.random.shuffle].
llvm-svn: 104708
Diffstat (limited to 'libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp')
-rw-r--r--libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
index 23a7c1f9919..6513d0c003a 100644
--- a/libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
+++ b/libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -9,14 +9,23 @@
// <algorithm>
-// template<RandomAccessIterator Iter, UniformRandomNumberGenerator Rand>
-// void
-// random_shuffle(Iter first, Iter last, Rand&& g);
+// template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+// void shuffle(RandomAccessIterator first, RandomAccessIterator last,
+// UniformRandomNumberGenerator& g);
#include <algorithm>
-
-#error random_shuffle for UniformRandomNumberGenerator not implemented
+#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));
}
OpenPOWER on IntegriCloud