aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn')
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp75
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp41
17 files changed, 920 insertions, 0 deletions
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
new file mode 100644
index 000000000000..57724ae10a70
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
new file mode 100644
index 000000000000..9535ed0295d4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s1(new A);
+ A* p = s1.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(A::count == 1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5));
+ A* p = s1.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s1.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter<A> d1(5);
+ std::unique_ptr<A, CDeleter<A>&> s1(new A, d1);
+ A* p = s1.get();
+ CDeleter<A> d2(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, d2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(d1.state() == 5);
+ assert(d2.state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
new file mode 100644
index 000000000000..5046fd8aae6b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
new file mode 100644
index 000000000000..aa4fdb8a96b1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
new file mode 100644
index 000000000000..e0d7c891c80f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
new file mode 100644
index 000000000000..3fd2cbc42bd6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
new file mode 100644
index 000000000000..989f594e38b8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
new file mode 100644
index 000000000000..0f900603e239
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
new file mode 100644
index 000000000000..a448c77a66a7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
new file mode 100644
index 000000000000..f35af9f453ff
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
new file mode 100644
index 000000000000..9aea81a8b144
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ CDeleter<B> db(5);
+ std::unique_ptr<B, CDeleter<B>&> s(new B, db);
+ A* p = s.get();
+ CDeleter<A> da(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s.get_deleter().state() == 5);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
new file mode 100644
index 000000000000..dba901b2ce17
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
new file mode 100644
index 000000000000..4694986c6773
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
new file mode 100644
index 000000000000..220677cd6fa7
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ const std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
new file mode 100644
index 000000000000..56ab43c7de24
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[], Deleter> s;
+ std::unique_ptr<A, Deleter> s2;
+ s2 = std::move(s);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
new file mode 100644
index 000000000000..e2d7956cda64
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = 0;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
new file mode 100644
index 000000000000..fb1584951993
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = nullptr;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}