mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-22 16:37:40 +08:00
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:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user