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



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287866 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roger Ferrer Ibanez
2016-11-24 11:17:09 +00:00
parent 37a0d7cb33
commit 01b9f8a698
4 changed files with 44 additions and 8 deletions

View File

@@ -7,7 +7,6 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <memory> // <memory>
// template <class InputIterator, class ForwardIterator> // template <class InputIterator, class ForwardIterator>
@@ -18,13 +17,21 @@
#include <memory> #include <memory>
#include <cassert> #include <cassert>
#include "test_macros.h"
struct B struct B
{ {
static int count_; static int count_;
static int population_; static int population_;
int data_; int data_;
explicit B() : data_(1) { ++population_; } 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_; } ~B() {data_ = 0; --population_; }
}; };
@@ -49,6 +56,7 @@ int main()
B* bp = (B*)pool; B* bp = (B*)pool;
B b[N]; B b[N];
assert(B::population_ == N); assert(B::population_ == N);
#ifndef TEST_HAS_NO_EXCEPTIONS
try try
{ {
std::uninitialized_copy(b, b+N, bp); std::uninitialized_copy(b, b+N, bp);
@@ -58,6 +66,7 @@ int main()
{ {
assert(B::population_ == N); assert(B::population_ == N);
} }
#endif
B::count_ = 0; B::count_ = 0;
std::uninitialized_copy(b, b+2, bp); std::uninitialized_copy(b, b+2, bp);
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)

View File

@@ -7,7 +7,6 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <memory> // <memory>
// template <class InputIterator, class Size, class ForwardIterator> // template <class InputIterator, class Size, class ForwardIterator>
@@ -18,13 +17,21 @@
#include <memory> #include <memory>
#include <cassert> #include <cassert>
#include "test_macros.h"
struct B struct B
{ {
static int count_; static int count_;
static int population_; static int population_;
int data_; int data_;
explicit B() : data_(1) { ++population_; } 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_; } ~B() {data_ = 0; --population_; }
}; };
@@ -49,6 +56,7 @@ int main()
B* bp = (B*)pool; B* bp = (B*)pool;
B b[N]; B b[N];
assert(B::population_ == N); assert(B::population_ == N);
#ifndef TEST_HAS_NO_EXCEPTIONS
try try
{ {
std::uninitialized_copy_n(b, 5, bp); std::uninitialized_copy_n(b, 5, bp);
@@ -58,6 +66,7 @@ int main()
{ {
assert(B::population_ == N); assert(B::population_ == N);
} }
#endif
B::count_ = 0; B::count_ = 0;
std::uninitialized_copy_n(b, 2, bp); std::uninitialized_copy_n(b, 2, bp);
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)

View File

@@ -7,7 +7,6 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <memory> // <memory>
// template <class ForwardIterator, class Size, class T> // template <class ForwardIterator, class Size, class T>
@@ -17,13 +16,21 @@
#include <memory> #include <memory>
#include <cassert> #include <cassert>
#include "test_macros.h"
struct B struct B
{ {
static int count_; static int count_;
static int population_; static int population_;
int data_; int data_;
explicit B() : data_(1) { ++population_; } 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_; } ~B() {data_ = 0; --population_; }
}; };
@@ -47,6 +54,7 @@ int main()
char pool[sizeof(B)*N] = {0}; char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool; B* bp = (B*)pool;
assert(B::population_ == 0); assert(B::population_ == 0);
#ifndef TEST_HAS_NO_EXCEPTIONS
try try
{ {
std::uninitialized_fill_n(bp, 5, B()); std::uninitialized_fill_n(bp, 5, B());
@@ -56,6 +64,7 @@ int main()
{ {
assert(B::population_ == 0); assert(B::population_ == 0);
} }
#endif
B::count_ = 0; B::count_ = 0;
B* r = std::uninitialized_fill_n(bp, 2, B()); B* r = std::uninitialized_fill_n(bp, 2, B());
assert(r == bp + 2); assert(r == bp + 2);

View File

@@ -7,7 +7,6 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <memory> // <memory>
// template <class ForwardIterator, class T> // template <class ForwardIterator, class T>
@@ -18,13 +17,21 @@
#include <memory> #include <memory>
#include <cassert> #include <cassert>
#include "test_macros.h"
struct B struct B
{ {
static int count_; static int count_;
static int population_; static int population_;
int data_; int data_;
explicit B() : data_(1) { ++population_; } 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_; } ~B() {data_ = 0; --population_; }
}; };
@@ -48,6 +55,7 @@ int main()
char pool[sizeof(B)*N] = {0}; char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool; B* bp = (B*)pool;
assert(B::population_ == 0); assert(B::population_ == 0);
#ifndef TEST_HAS_NO_EXCEPTIONS
try try
{ {
std::uninitialized_fill(bp, bp+N, B()); std::uninitialized_fill(bp, bp+N, B());
@@ -57,6 +65,7 @@ int main()
{ {
assert(B::population_ == 0); assert(B::population_ == 0);
} }
#endif
B::count_ = 0; B::count_ = 0;
std::uninitialized_fill(bp, bp+2, B()); std::uninitialized_fill(bp, bp+2, B());
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)