summaryrefslogtreecommitdiffstats
path: root/libcxx/test/thread
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/thread')
-rw-r--r--libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp33
-rw-r--r--libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp27
2 files changed, 60 insertions, 0 deletions
diff --git a/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp b/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
index 3b473508346..70a4e00b0d6 100644
--- a/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
+++ b/libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
@@ -20,6 +20,7 @@
#include <cassert>
#include "../test_allocator.h"
+#include "min_allocator.h"
int main()
{
@@ -48,4 +49,36 @@ int main()
assert(f.valid());
}
assert(test_alloc_base::count == 0);
+ // Test with a minimal allocator
+ {
+ std::promise<int> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, bare_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, bare_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
+ // Test with a minimal allocator that returns class-type pointers
+ {
+ std::promise<int> p(std::allocator_arg, min_allocator<void>());
+ std::future<int> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<int&> p(std::allocator_arg, min_allocator<void>());
+ std::future<int&> f = p.get_future();
+ assert(f.valid());
+ }
+ {
+ std::promise<void> p(std::allocator_arg, min_allocator<void>());
+ std::future<void> f = p.get_future();
+ assert(f.valid());
+ }
}
diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
index 347c5cd399e..3aac2b26bfc 100644
--- a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
+++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
@@ -20,6 +20,7 @@
#include <cassert>
#include "../../test_allocator.h"
+#include "min_allocator.h"
class A
{
@@ -94,4 +95,30 @@ int main()
assert(f.get() == 4);
}
assert(test_alloc_base::count == 0);
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ bare_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
+ {
+ std::packaged_task<double(int, char)> p(std::allocator_arg,
+ min_allocator<void>(), A(5));
+ assert(p.valid());
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ assert(A::n_copies == 0);
+ assert(A::n_moves > 0);
+ }
+ A::n_copies = 0;
+ A::n_moves = 0;
}
OpenPOWER on IntegriCloud