Protect tests for std::uninitialized_{copy,fill} under libcpp-no-exceptions
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Thu, 24 Nov 2016 11:17:09 +0000 (11:17 +0000)
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Thu, 24 Nov 2016 11:17:09 +0000 (11:17 +0000)
Skip tests that expect an exception be thrown.

Differential Revision: https://reviews.llvm.org/D26606

llvm-svn: 287866

libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp

index 1debd6d..1829dff 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <memory>
 
 // template <class InputIterator, class ForwardIterator>
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 struct B
 {
     static int count_;
     static int population_;
     int data_;
     explicit B() : data_(1) { ++population_; }
-    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+    B(const B &b) {
+      ++count_;
+      if (count_ == 3)
+        TEST_THROW(1);
+      data_ = b.data_;
+      ++population_;
+    }
     ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@ int main()
     B* bp = (B*)pool;
     B b[N];
     assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
     {
         std::uninitialized_copy(b, b+N, bp);
@@ -58,6 +66,7 @@ int main()
     {
         assert(B::population_ == N);
     }
+#endif
     B::count_ = 0;
     std::uninitialized_copy(b, b+2, bp);
     for (int i = 0; i < 2; ++i)
index 83aa194..af20cd2 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <memory>
 
 // template <class InputIterator, class Size, class ForwardIterator>
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 struct B
 {
     static int count_;
     static int population_;
     int data_;
     explicit B() : data_(1) { ++population_; }
-    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+    B(const B &b) {
+      ++count_;
+      if (count_ == 3)
+        TEST_THROW(1);
+      data_ = b.data_;
+      ++population_;
+    }
     ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@ int main()
     B* bp = (B*)pool;
     B b[N];
     assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
     {
         std::uninitialized_copy_n(b, 5, bp);
@@ -58,6 +66,7 @@ int main()
     {
         assert(B::population_ == N);
     }
+#endif
     B::count_ = 0;
     std::uninitialized_copy_n(b, 2, bp);
     for (int i = 0; i < 2; ++i)
index 5f90a37..862e5be 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <memory>
 
 // template <class ForwardIterator, class Size, class T>
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 struct B
 {
     static int count_;
     static int population_;
     int data_;
     explicit B() : data_(1) { ++population_; }
-    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+    B(const B &b) {
+      ++count_;
+      if (count_ == 3)
+        TEST_THROW(1);
+      data_ = b.data_;
+      ++population_;
+    }
     ~B() {data_ = 0; --population_; }
 };
 
@@ -47,6 +54,7 @@ int main()
     char pool[sizeof(B)*N] = {0};
     B* bp = (B*)pool;
     assert(B::population_ == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
     {
         std::uninitialized_fill_n(bp, 5, B());
@@ -56,6 +64,7 @@ int main()
     {
         assert(B::population_ == 0);
     }
+#endif
     B::count_ = 0;
     B* r = std::uninitialized_fill_n(bp, 2, B());
     assert(r == bp + 2);
index 3816a25..57438e9 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <memory>
 
 // template <class ForwardIterator, class T>
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 struct B
 {
     static int count_;
     static int population_;
     int data_;
     explicit B() : data_(1) { ++population_; }
-    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+    B(const B &b) {
+      ++count_;
+      if (count_ == 3)
+        TEST_THROW(1);
+      data_ = b.data_;
+      ++population_;
+    }
     ~B() {data_ = 0; --population_; }
 };
 
@@ -48,6 +55,7 @@ int main()
     char pool[sizeof(B)*N] = {0};
     B* bp = (B*)pool;
     assert(B::population_ == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
     {
         std::uninitialized_fill(bp, bp+N, B());
@@ -57,6 +65,7 @@ int main()
     {
         assert(B::population_ == 0);
     }
+#endif
     B::count_ = 0;
     std::uninitialized_fill(bp, bp+2, B());
     for (int i = 0; i < 2; ++i)