summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers')
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp24
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp40
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp25
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp38
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp48
-rw-r--r--libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp31
6 files changed, 200 insertions, 6 deletions
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
index 08092ec2ab1..b70f865d5b7 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
@@ -1 +1,23 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test op*() #include <memory> #include <cassert> int main() { std::unique_ptr<int> p(new int(3)); assert(*p == 3); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int> p(new int(3));
+ assert(*p == 3);
+}
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
index 3fbfb3826a5..7982f9e59a0 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
@@ -1 +1,39 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test op*() #include <memory> #include <cassert> int main() { { std::unique_ptr<int> p(new int(3)); if (p) ; else assert(false); if (!p) assert(false); } { std::unique_ptr<int> p; if (!p) ; else assert(false); if (p) assert(false); } } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ std::unique_ptr<int> p(new int(3));
+ if (p)
+ ;
+ else
+ assert(false);
+ if (!p)
+ assert(false);
+ }
+ {
+ std::unique_ptr<int> p;
+ if (!p)
+ ;
+ else
+ assert(false);
+ if (p)
+ assert(false);
+ }
+}
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
index d453724c0e8..62bc3269e68 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
@@ -1 +1,24 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test get #include <memory> #include <cassert> int main() { int* p = new int; std::unique_ptr<int> s(p); assert(s.get() == p); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int;
+ std::unique_ptr<int> s(p);
+ assert(s.get() == p);
+}
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
index 8cefe172f38..34504b6b8c9 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
@@ -1 +1,37 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test get_deleter() #include <memory> #include <cassert> struct Deleter { void operator()(void*) {} int test() {return 5;} int test() const {return 6;} }; int main() { { std::unique_ptr<int, Deleter> p; assert(p.get_deleter().test() == 5); } { const std::unique_ptr<int, Deleter> p; assert(p.get_deleter().test() == 6); } } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+ void operator()(void*) {}
+
+ int test() {return 5;}
+ int test() const {return 6;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 5);
+ }
+ {
+ const std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 6);
+ }
+}
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
index 4e9657067ed..93807cc1874 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
@@ -1 +1,47 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test op[](size_t) #include <memory> #include <cassert> class A { int state_; static int next_; public: A() : state_(++next_) {} int get() const {return state_;} friend bool operator==(const A& x, int y) {return x.state_ == y;} A& operator=(int i) {state_ = i; return *this;} }; int A::next_ = 0; int main() { std::unique_ptr<A> p(new A[3]); assert(p[0] == 1); assert(p[1] == 2); assert(p[2] == 3); p[0] = 3; p[1] = 2; p[2] = 1; assert(p[0] == 3); assert(p[1] == 2); assert(p[2] == 1); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+ int state_;
+ static int next_;
+public:
+ A() : state_(++next_) {}
+ int get() const {return state_;}
+
+ friend bool operator==(const A& x, int y)
+ {return x.state_ == y;}
+
+ A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+ std::unique_ptr<A> p(new A[3]);
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3);
+ p[0] = 3;
+ p[1] = 2;
+ p[2] = 1;
+ assert(p[0] == 3);
+ assert(p[1] == 2);
+ assert(p[2] == 1);
+}
diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
index 4a00ea233e5..eb63dc2444b 100644
--- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
+++ b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
@@ -1 +1,30 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // unique_ptr // test op->() #include <memory> #include <cassert> struct A { int i_; A() : i_(7) {} }; int main() { std::unique_ptr<A> p(new A); assert(p->i_ == 7); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ int i_;
+
+ A() : i_(7) {}
+};
+
+int main()
+{
+ std::unique_ptr<A> p(new A);
+ assert(p->i_ == 7);
+}
OpenPOWER on IntegriCloud