summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/memory
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-11-02 15:29:13 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-11-02 15:29:13 +0000
commit79dfd99d305446a0857cc9d58057d5a3bdcfa62f (patch)
tree25f9caef2d66938d9756e5adf55066574a5210da /libcxx/test/std/utilities/memory
parentdc39f313e2a14900f0d0e6cc156f35cef47f282d (diff)
downloadbcm5719-llvm-79dfd99d305446a0857cc9d58057d5a3bdcfa62f.tar.gz
bcm5719-llvm-79dfd99d305446a0857cc9d58057d5a3bdcfa62f.zip
Remove undefined behavior from some tests. Same pattern as the unitialized_copy tests
llvm-svn: 251804
Diffstat (limited to 'libcxx/test/std/utilities/memory')
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp13
-rw-r--r--libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp13
2 files changed, 16 insertions, 10 deletions
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 d2b1dfa2886..ee4b04bd522 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
@@ -19,13 +19,15 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
int B::count_ = 0;
+int B::population_ = 0;
struct Nasty
{
@@ -43,6 +45,7 @@ int main()
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
+ assert(B::population_ == 0);
try
{
std::uninitialized_fill_n(bp, 5, B());
@@ -50,14 +53,14 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == 0);
}
B::count_ = 0;
B* r = std::uninitialized_fill_n(bp, 2, B());
assert(r == bp + 2);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == 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 47cabdfa478..d24da4855ea 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
@@ -20,13 +20,15 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
int B::count_ = 0;
+int B::population_ = 0;
struct Nasty
{
@@ -44,6 +46,7 @@ int main()
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
+ assert(B::population_ == 0);
try
{
std::uninitialized_fill(bp, bp+N, B());
@@ -51,13 +54,13 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == 0);
}
B::count_ = 0;
std::uninitialized_fill(bp, bp+2, B());
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == 2);
}
{
const int N = 5;
OpenPOWER on IntegriCloud