[libcxx] r276585 - Fix portability issues in <random> tests. Patch from STL at microsoft.com

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 24 16:36:19 PDT 2016


Author: ericwf
Date: Sun Jul 24 18:36:18 2016
New Revision: 276585

URL: http://llvm.org/viewvc/llvm-project?rev=276585&view=rev
Log:
Fix portability issues in <random> tests. Patch from STL at microsoft.com

Modified:
    libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
    libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
    libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
    libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp

Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp Sun Jul 24 18:36:18 2016
@@ -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));
 }

Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp Sun Jul 24 18:36:18 2016
@@ -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));
 }

Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp Sun Jul 24 18:36:18 2016
@@ -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));
 }

Modified: libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp Sun Jul 24 18:36:18 2016
@@ -14,9 +14,11 @@
 #include <random>
 #include <cassert>
 
+#include "test_macros.h"
+
 int main()
 {
     std::default_random_engine e;
     e.discard(9999);
-    assert(e() == 399268537u);
+    LIBCPP_ASSERT(e() == 399268537u);
 }




More information about the cfe-commits mailing list