diff options
author | Roger Ferrer Ibanez <roger.ferreribanez@arm.com> | 2016-11-24 11:17:09 +0000 |
---|---|---|
committer | Roger Ferrer Ibanez <roger.ferreribanez@arm.com> | 2016-11-24 11:17:09 +0000 |
commit | 929282836ae3b3412e5435a641dd2514a6019d9c (patch) | |
tree | bd6555a107e39633967b6f294a8327bb74be3948 /libcxx/test/std | |
parent | c65daf3e4ae4b00fbd8514ac8df9ac216a4d0822 (diff) | |
download | bcm5719-llvm-929282836ae3b3412e5435a641dd2514a6019d9c.tar.gz bcm5719-llvm-929282836ae3b3412e5435a641dd2514a6019d9c.zip |
Protect tests for std::uninitialized_{copy,fill} under libcpp-no-exceptions
Skip tests that expect an exception be thrown.
Differential Revision: https://reviews.llvm.org/D26606
llvm-svn: 287866
Diffstat (limited to 'libcxx/test/std')
4 files changed, 44 insertions, 8 deletions
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp index 1debd6d75ff..1829dff354d 100644 --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <memory> // template <class InputIterator, class ForwardIterator> @@ -18,13 +17,21 @@ #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) diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp index 83aa19471ad..af20cd22029 100644 --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <memory> // template <class InputIterator, class Size, class ForwardIterator> @@ -18,13 +17,21 @@ #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) diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp index 5f90a379206..862e5be8e36 100644 --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <memory> // template <class ForwardIterator, class Size, class T> @@ -17,13 +16,21 @@ #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); diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp index 3816a252868..57438e9cb0d 100644 --- a/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <memory> // template <class ForwardIterator, class T> @@ -18,13 +17,21 @@ #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) |