summaryrefslogtreecommitdiffstats
path: root/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commita90c6dd46005b2b14de3bb889a8d03bb34bd3256 (patch)
tree81065ae44967d68964de1f2fdfa107623e58e8a4 /test/std/thread/futures/futures.promise/move_ctor.pass.cpp
parent669a8a5a1929e881258bfed10d7461ca42ea0a9e (diff)
downloadexternal_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.gz
external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.bz2
external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.zip
Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/thread/futures/futures.promise/move_ctor.pass.cpp')
-rw-r--r--test/std/thread/futures/futures.promise/move_ctor.pass.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
new file mode 100644
index 000000000..eeec4fb15
--- /dev/null
+++ b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class promise<R>
+
+// promise(promise&& rhs);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<int> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+ std::promise<int&> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<int&> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+ {
+ std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+ std::promise<void> p(std::move(p0));
+ assert(test_alloc_base::count == 1);
+ std::future<void> f = p.get_future();
+ assert(test_alloc_base::count == 1);
+ assert(f.valid());
+ try
+ {
+ f = p0.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ assert(test_alloc_base::count == 1);
+ }
+ assert(test_alloc_base::count == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}