summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.modifying.operations
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-24 23:36:18 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-24 23:36:18 +0000
commit16629519740e6ba198b83273b50c1c010eb4a829 (patch)
tree8d9835c968190d319acc4cdbedd3df2e929e8969 /libcxx/test/std/algorithms/alg.modifying.operations
parent307e4216b26dceebbfbf3451a3c1c020274928af (diff)
downloadbcm5719-llvm-16629519740e6ba198b83273b50c1c010eb4a829.tar.gz
bcm5719-llvm-16629519740e6ba198b83273b50c1c010eb4a829.zip
Fix portability issues in <random> tests. Patch from STL@microsoft.com
llvm-svn: 276585
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp8
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp5
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp8
3 files changed, 16 insertions, 5 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index a14ccf9e5e6..e24598a9bc1 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -17,6 +17,8 @@
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
int ia[] = {1, 2, 3, 4};
@@ -24,7 +26,9 @@ int main()
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));
+ LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+ assert(std::is_permutation(ia, ia+sa, ia1));
std::random_shuffle(ia, ia+sa);
- assert(std::equal(ia, ia+sa, ia2));
+ LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+ assert(std::is_permutation(ia, ia+sa, ia2));
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
index b944c89e351..967b6e37762 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -18,6 +18,8 @@
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
+
struct gen
{
int operator()(int n)
@@ -33,5 +35,6 @@ int main()
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
gen r;
std::random_shuffle(ia, ia+sa, r);
- assert(std::equal(ia, ia+sa, ia1));
+ LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+ assert(std::is_permutation(ia, ia+sa, ia1));
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
index 343ae90101f..0c35ed73ee4 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -17,6 +17,8 @@
#include <random>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -25,7 +27,9 @@ int main()
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));
+ LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+ assert(std::is_permutation(ia, ia+sa, ia1));
std::shuffle(ia, ia+sa, g);
- assert(std::equal(ia, ia+sa, ia2));
+ LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+ assert(std::is_permutation(ia, ia+sa, ia2));
}
OpenPOWER on IntegriCloud