summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/unique_ptr
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/20_util/unique_ptr
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/unique_ptr')
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc78
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc50
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc53
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc52
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc46
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc54
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc37
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc46
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc36
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc35
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc52
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc117
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc85
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc41
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc68
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc57
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc48
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc55
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc41
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc24
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc50
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc68
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc68
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc47
25 files changed, 1346 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
new file mode 100644
index 000000000..99b412b58
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct Deleter
+{
+ Deleter() = default;
+ Deleter(const Deleter&) = default;
+ Deleter(Deleter&&) = default;
+
+ Deleter&
+ operator=(const Deleter&)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( true );
+ return *this;
+ }
+
+ Deleter&
+ operator=(Deleter&&)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( false );
+ return *this;
+ }
+
+ template<class T>
+ void
+ operator()(T*) const { }
+};
+
+struct DDeleter : Deleter { };
+
+// libstdc++/48635
+void test01()
+{
+ Deleter d;
+
+ std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d);
+ p2 = std::move(p1);
+
+ DDeleter dd;
+
+ std::unique_ptr<int, DDeleter&> p1t(nullptr, dd);
+ std::unique_ptr<int, Deleter&> p2t(nullptr, d);
+ p2t = std::move(p1t);
+
+ std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d);
+ p2a = std::move(p1a);
+
+ std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd);
+ std::unique_ptr<int[], Deleter&> p2at(nullptr, d);
+ p2at = std::move(p1at);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc
new file mode 100644
index 000000000..1ed53ee2d
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+
+struct D;
+
+struct B
+{
+ B& operator=(D&) = delete; // { dg-error "declared here" }
+
+ template<class T>
+ void operator()(T*) const {}
+};
+
+struct D : B { };
+
+// libstdc++/48635
+void f()
+{
+ B b;
+ D d;
+
+ std::unique_ptr<int, B&> ub(nullptr, b);
+ std::unique_ptr<int, D&> ud(nullptr, d);
+ ub = std::move(ud);
+// { dg-error "use of deleted function" "" { target *-*-* } 189 }
+
+ std::unique_ptr<int[], B&> uba(nullptr, b);
+ std::unique_ptr<int[], D&> uda(nullptr, d);
+ uba = std::move(uda);
+// { dg-error "use of deleted function" "" { target *-*-* } 329 }
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
new file mode 100644
index 000000000..501bad385
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
@@ -0,0 +1,53 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009, 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+
+struct base { virtual ~base() {} };
+struct derived : base {};
+
+void
+test01()
+{
+ std::unique_ptr<derived> p1(new derived);
+ std::unique_ptr<derived> p2(new derived);
+// p2 = p1; // should not compile
+ p2 = std::move(p1);
+ std::unique_ptr<base> p3(new base);
+// p3 = p2; // should not compile
+ p3 = std::move(p2);
+}
+
+void
+test02()
+{
+ std::unique_ptr<int[]> p1(new int(420));
+ std::unique_ptr<int[]> p2 = p1; // { dg-error "deleted" }
+}
+
+void
+test03()
+{
+ std::unique_ptr<int[2]> p1(new int[3]); // { dg-error "no match" }
+ // { dg-error "candidate" "candidate-note" { target *-*-* } 48 }
+ std::unique_ptr<int[2]> p2 = p1; // { dg-error "deleted" }
+}
+
+// { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc
new file mode 100644
index 000000000..75529c969
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct B { virtual ~B() {} };
+struct D : public B {};
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ D *d = new D;
+ std::unique_ptr<D> p1(d);
+ std::unique_ptr<D> p2(new D);
+ p2 = std::move(p1);
+
+ VERIFY( p1.get() == 0 );
+ VERIFY( p2.get() == d );
+
+ std::unique_ptr<B> p3(new B);
+ p3 = std::move(p2);
+
+ VERIFY( p2.get() == 0 );
+ VERIFY( p3.get() == d );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc
new file mode 100644
index 000000000..b1b878d5d
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct B { virtual ~B() {} };
+struct D : public B {};
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ D *d = new D[3];
+ std::unique_ptr<D[]> p1(d);
+ std::unique_ptr<D[]> p2;
+ p2 = std::move(p1);
+
+ VERIFY( p1.get() == 0 );
+ VERIFY( p2.get() == d );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc
new file mode 100644
index 000000000..6f067ee4d
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> p(new A);
+ p = nullptr;
+
+ VERIFY( p.get() == nullptr );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A[]> p(new A[2]);
+ p = nullptr;
+
+ VERIFY( p.get() == nullptr );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc
new file mode 100644
index 000000000..e3dfad46f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+
+// libstdc++/42925 (also see GB 99)
+void test01()
+{
+ std::unique_ptr<int> ptr;
+ if (ptr == 0)
+ { }
+ if (0 == ptr)
+ { }
+ if (ptr != 0)
+ { }
+ if (0 != ptr)
+ { }
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc
new file mode 100644
index 000000000..f4b9838d0
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor]
+
+// Construction from auto_ptr
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::auto_ptr<A> a(new A);
+ std::unique_ptr<A> a2(std::move(a));
+ VERIFY( a.get() == nullptr );
+ VERIFY( a2.get() != 0 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc
new file mode 100644
index 000000000..76910c3c6
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+
+struct A { };
+
+// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor]
+
+// Construction from const auto_ptr
+void
+test01()
+{
+ const std::auto_ptr<A> a(new A);
+ std::unique_ptr<A> a2(std::move(a)); // { dg-error "no match" }
+}
+// { dg-excess-errors "candidates are" }
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc
new file mode 100644
index 000000000..fbe9821f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" }
+// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2Ev" } }
+// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2EDn" } }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_common_types.h>
+
+int main()
+{
+ __gnu_test::constexpr_default_constructible test1; //not literal
+ test1.operator()<std::unique_ptr<int>>();
+
+ __gnu_test::constexpr_single_value_constructible test2; //not literal
+ test2.operator()<std::unique_ptr<int>, std::nullptr_t>();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc
new file mode 100644
index 000000000..1f515ea53
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A { };
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> p = nullptr;
+
+ VERIFY( p.get() == nullptr );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A[]> p = nullptr;
+
+ VERIFY( p.get() == nullptr );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc
new file mode 100644
index 000000000..324264b24
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc
@@ -0,0 +1,117 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+// 20.6.11.2.1 unique_ptr constructors [unique.ptr.single.ctor]
+
+// Construction from pointer
+void
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> A_default;
+ VERIFY( A_default.get() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ std::unique_ptr<A> A_from_A(new A);
+ VERIFY( A_from_A.get() != 0 );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ std::unique_ptr<A> A_from_B(new B);
+ VERIFY( A_from_B.get() != 0 );
+ VERIFY( A::ctor_count == 2 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 1 );
+ VERIFY( B::dtor_count == 0 );
+}
+
+void
+test02()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ A * const A_default = 0;
+ std::unique_ptr<A> p1(A_default);
+ VERIFY( p1.get() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ A * const A_from_A = new A;
+ std::unique_ptr<A> p2(A_from_A);
+ VERIFY( p2.get() == A_from_A );
+ VERIFY( A::ctor_count == 1 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc
new file mode 100644
index 000000000..dcd6e92f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc
@@ -0,0 +1,85 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ A() { ++ctor_count; }
+ virtual ~A() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long A::ctor_count = 0;
+long A::dtor_count = 0;
+
+struct B : A
+{
+ B() { ++ctor_count; }
+ virtual ~B() { ++dtor_count; }
+ static long ctor_count;
+ static long dtor_count;
+};
+long B::ctor_count = 0;
+long B::dtor_count = 0;
+
+
+struct reset_count_struct
+{
+ ~reset_count_struct()
+ {
+ A::ctor_count = 0;
+ A::dtor_count = 0;
+ B::ctor_count = 0;
+ B::dtor_count = 0;
+ }
+};
+
+
+// 20.4.5.1 unique_ptr constructors [unique.ptr.cons]
+
+// Construction from pointer
+void
+test01()
+{
+ reset_count_struct __attribute__((unused)) reset;
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A[]> A_default;
+ VERIFY( A_default.get() == 0 );
+ VERIFY( A::ctor_count == 0 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+
+ std::unique_ptr<A[]> A_from_A(new A[3]);
+ VERIFY( A_from_A.get() != 0 );
+ VERIFY( A::ctor_count == 3 );
+ VERIFY( A::dtor_count == 0 );
+ VERIFY( B::ctor_count == 0 );
+ VERIFY( B::dtor_count == 0 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc
new file mode 100644
index 000000000..2a4a89b40
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc
@@ -0,0 +1,41 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+
+struct A
+{
+};
+
+struct B : A
+{
+ virtual ~B() { }
+};
+
+// 20.4.5.1 unique_ptr constructors [unique.ptr.cons]
+
+// Construction from pointer of derived type
+void
+test01()
+{
+ std::unique_ptr<B[]> B_from_A(new A[3]); //{ dg-error "invalid conversion from" }
+}
+
+// { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc
new file mode 100644
index 000000000..7e88eb948
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc
@@ -0,0 +1,68 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do run }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+static int count;
+
+void del(int* p) { ++count; delete p; }
+void vdel(int* p) { ++count; delete[] p; }
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ count = 0;
+ {
+ std::unique_ptr<int, void(*)(int*)> p(nullptr, del);
+ }
+ VERIFY( count == 0 );
+ {
+ std::unique_ptr<int, void(*)(int*)> p(new int, del);
+ }
+ VERIFY( count == 1 );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+ count = 0;
+ {
+ std::unique_ptr<int[], void(*)(int*)> p(nullptr, vdel);
+ }
+ VERIFY( count == 0 );
+ {
+ std::unique_ptr<int[], void(*)(int*)> p(new int[1], vdel);
+ }
+ VERIFY( count == 1 );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc
new file mode 100644
index 000000000..e765874c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc
@@ -0,0 +1,57 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+using std::unique_ptr;
+
+// { dg-excess-errors "static assertion failed" }
+
+void
+test01()
+{
+ unique_ptr<int, void(*)(int*)> p1; // { dg-error "here" }
+
+ unique_ptr<int, void(*)(int*)> p2(nullptr); // { dg-error "here" }
+
+ unique_ptr<int, void(*)(int*)> p3(new int); // { dg-error "here" }
+}
+
+void
+test02()
+{
+ unique_ptr<int[], void(*)(int*)> p1; // { dg-error "here" }
+
+ unique_ptr<int[], void(*)(int*)> p2(nullptr); // { dg-error "here" }
+
+ unique_ptr<int[], void(*)(int*)> p3(new int[1]); // { dg-error "here" }
+}
+
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc
new file mode 100644
index 000000000..53ece26ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ struct T { };
+
+ std::unique_ptr<T> u0(new T);
+ std::hash<std::unique_ptr<T>> hu0;
+ std::hash<typename std::unique_ptr<T>::pointer> hp0;
+
+ VERIFY( hu0(u0) == hp0(u0.get()) );
+
+ std::unique_ptr<T[]> u1(new T[10]);
+ std::hash<std::unique_ptr<T[]>> hu1;
+ std::hash<typename std::unique_ptr<T[]>::pointer> hp1;
+
+ VERIFY( hu1(u1) == hp1(u1.get()) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc
new file mode 100644
index 000000000..6dcf72919
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10.2.5 unique_ptr modifiers [unique.ptr.single.modifiers]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct D
+{
+ static int count;
+
+ void operator()(int* p) const
+ {
+ ++count;
+ delete p;
+ }
+};
+int D::count = 0;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<int, D> up;
+ up.reset();
+ VERIFY( D::count == 0 );
+ up.reset(new int);
+ VERIFY( D::count == 0 );
+ up.reset(up.get());
+ VERIFY( D::count == 1 );
+ up.release();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc
new file mode 100644
index 000000000..54948df4b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc
@@ -0,0 +1,41 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.7.1 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+
+// PR libstdc++/48398
+
+struct my_deleter
+{
+ typedef int* pointer;
+
+ void operator()( pointer p ) { delete p; }
+};
+
+void test01()
+{
+ std::unique_ptr<void, my_deleter> p( new int() );
+
+ p.get();
+ p.reset();
+
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc
new file mode 100644
index 000000000..29bb57d22
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009, 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+
+struct A
+{
+};
+
+struct B : A
+{
+ virtual ~B() { }
+};
+
+void test01()
+{
+ std::unique_ptr<B[]> up;
+ up.reset(new A[3]); // { dg-error "deleted" }
+}
+
+// { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc
new file mode 100644
index 000000000..dd308094b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc
@@ -0,0 +1,24 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+
+template class std::unique_ptr<int>;
+template class std::unique_ptr<int[]>;
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc
new file mode 100644
index 000000000..55f28caaa
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc
@@ -0,0 +1,50 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010, 2011 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr.single]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ void operator()(void*) const { }
+};
+
+struct B
+{
+ typedef char* pointer;
+ void operator()(pointer) const { }
+};
+
+int main()
+{
+ typedef std::unique_ptr<int> up;
+ typedef std::unique_ptr<int, A> upA;
+ typedef std::unique_ptr<int, B> upB;
+ typedef std::unique_ptr<int, A&> upAr;
+ typedef std::unique_ptr<int, B&> upBr;
+
+ static_assert( std::is_same< up::pointer, int*>::value, "" );
+ static_assert( std::is_same< upA::pointer, int*>::value, "" );
+ static_assert( std::is_same< upB::pointer, char*>::value, "" );
+ static_assert( std::is_same< upAr::pointer, int*>::value, "" );
+ static_assert( std::is_same< upBr::pointer, char*>::value, "" );
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc
new file mode 100644
index 000000000..70bf90905
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc
@@ -0,0 +1,68 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ virtual ~A() { }
+};
+
+struct B : A
+{
+};
+
+// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special]
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> p1;
+ std::unique_ptr<A> p2;
+
+ VERIFY( p1 == p2 );
+ VERIFY( !(p1 != p2) );
+ VERIFY( !(p1 < p2) && !(p1 > p2) );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> p1;
+ std::unique_ptr<A> p2(new A);
+
+ VERIFY( p1 != p2 );
+ VERIFY( !(p1 == p2) );
+ VERIFY( (p1 < p2) || (p1 > p2) );
+ VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc
new file mode 100644
index 000000000..ccb429282
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc
@@ -0,0 +1,68 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.6.11 Template class unique_ptr [unique.ptr]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ virtual ~A() { }
+};
+
+struct B : A
+{
+};
+
+// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special]
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A[]> p1;
+ std::unique_ptr<A[]> p2;
+
+ VERIFY( p1 == p2 );
+ VERIFY( !(p1 != p2) );
+ VERIFY( !(p1 < p2) && !(p1 > p2) );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A[]> p1;
+ std::unique_ptr<A[]> p2(new A[3]);
+
+ VERIFY( p1 != p2 );
+ VERIFY( !(p1 == p2) );
+ VERIFY( (p1 < p2) || (p1 > p2) );
+ VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc
new file mode 100644
index 000000000..fa0c31173
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A {};
+
+//20.6.11.5 unique_ptr specialized algorithms [unique.ptr.special]
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::unique_ptr<A> p1;
+ std::unique_ptr<A> p2(new A);
+ std::unique_ptr<A> p3;
+
+ std::swap(p3, p2);
+
+ VERIFY( p1 != p3 );
+ VERIFY( p2 != p3 );
+ VERIFY( p1 == p2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}