From 2561885f574ce7aedee4d30f3dbc6bfb09d64c06 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 15 Apr 2017 05:28:06 +0000 Subject: Rewrite and cleanup unique_ptr tests. This patch almost entirely rewrites the unique_ptr tests. There are a couple of reasons for this: A) Most of the *.fail.cpp tests were either incorrect or could be better written as a *.pass.cpp test that uses to check if certain operations are valid (Ex. Using static_assert(!std::is_copy_constructible_v) instead of writing a failure test). B) [unique.ptr.runtime] has very poor test coverage. Many of the constructors and assignment operators have to tests at all. The special members that have tests have very few test cases and are typically way out of date. C) The tests for [unique.ptr.single] and [unique.ptr.runtime] are largely duplicates of each other. This means common requirements have two different sets of tests in two different test files. This makes the tests harder to maintain than if there was a single copy. To address (A) this patch changes almost all of the *.fail.cpp tests into .pass.cpp tests using type traits; Allowing the *.fail.cpp tests to be removed. The address (B) and (C) the tests for [unique.ptr.single] and [unique.ptr.runtime] have been combined into a single directory, allowing both specializations to share common tests. Tests specific to the single/runtime specializations are given the suffix "*.single.pass.cpp" or "*.runtime.pass.cpp". Finally the unique.ptr test have been moved into the correct directory according to the standard. Specifically they have been removed from "utilities/memory" into "utilities/smartptr". PS. This patch also adds newly written tests for upcoming unique_ptr changes/fixes. However since these tests don't currently pass they are guarded by the macro TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES. This allows other STL's to validate the tests before libc++ implements the changes. The relevant libc++ changes should land in the next week. llvm-svn: 300388 --- .../memory/unique.ptr/nothing_to_do.pass.cpp | 12 - .../unique.ptr.create/make_unique.array.pass.cpp | 44 --- .../unique.ptr.create/make_unique.array1.fail.cpp | 17 -- .../unique.ptr.create/make_unique.array2.fail.cpp | 17 -- .../unique.ptr.create/make_unique.array3.fail.cpp | 17 -- .../unique.ptr.create/make_unique.array4.fail.cpp | 17 -- .../unique.ptr.create/make_unique.single.pass.cpp | 32 --- .../unique.ptr.dltr/nothing_to_do.pass.cpp | 12 - .../unique.ptr.dltr.dflt/convert_ctor.pass.cpp | 48 ---- .../unique.ptr.dltr.dflt/default.pass.cpp | 34 --- .../unique.ptr.dltr.dflt/incomplete.fail.cpp | 26 -- .../unique.ptr.dltr.dflt/void.fail.cpp | 24 -- .../unique.ptr.dltr.dflt1/convert_ctor.fail.cpp | 32 --- .../unique.ptr.dltr.dflt1/convert_ctor.pass.cpp | 28 -- .../unique.ptr.dltr.dflt1/default.pass.cpp | 36 --- .../unique.ptr.dltr.dflt1/incomplete.fail.cpp | 26 -- .../unique.ptr.dltr.general/nothing_to_do.pass.cpp | 12 - .../unique.ptr/unique.ptr.runtime/move01.fail.cpp | 28 -- .../unique.ptr/unique.ptr.runtime/move01.pass.cpp | 79 ------ .../unique.ptr/unique.ptr.runtime/move02.fail.cpp | 39 --- .../unique.ptr/unique.ptr.runtime/move03.fail.cpp | 57 ---- .../unique.ptr/unique.ptr.runtime/move04.fail.cpp | 57 ---- .../unique.ptr.runtime/move_convert01.fail.cpp | 57 ---- .../unique.ptr.runtime/move_convert02.fail.cpp | 61 ---- .../unique.ptr.runtime/move_convert03.fail.cpp | 62 ----- .../unique.ptr.runtime/move_convert04.fail.cpp | 57 ---- .../unique.ptr.runtime/move_convert05.fail.cpp | 61 ---- .../unique.ptr.runtime/move_convert06.fail.cpp | 62 ----- .../unique.ptr.runtime/move_convert07.fail.cpp | 56 ---- .../unique.ptr.runtime/move_convert08.fail.cpp | 60 ---- .../unique.ptr.runtime/move_convert09.fail.cpp | 62 ----- .../unique.ptr.runtime/null_asgn.pass.cpp | 41 --- .../unique.ptr.runtime/null_ctor.pass.cpp | 55 ---- .../unique.ptr.runtime/nullptr_asgn.pass.cpp | 41 --- .../unique.ptr.runtime/pointer_type.pass.cpp | 34 --- .../unique.ptr.runtime.ctor/default.pass.cpp | 50 ---- .../unique.ptr.runtime.ctor/default01.fail.cpp | 39 --- .../unique.ptr.runtime.ctor/default02.fail.cpp | 30 -- .../unique.ptr.runtime.ctor/default03.fail.cpp | 23 -- .../default_allows_incomplete.pass.cpp | 80 ------ .../unique.ptr.runtime.ctor/move01.fail.cpp | 42 --- .../unique.ptr.runtime.ctor/move01.pass.cpp | 70 ----- .../unique.ptr.runtime.ctor/move02.fail.cpp | 42 --- .../unique.ptr.runtime.ctor/move02.pass.cpp | 72 ----- .../unique.ptr.runtime.ctor/move03.fail.cpp | 55 ---- .../unique.ptr.runtime.ctor/move04.fail.cpp | 55 ---- .../move_convert01.fail.cpp | 57 ---- .../move_convert02.fail.cpp | 61 ---- .../move_convert03.fail.cpp | 78 ------ .../move_convert04.fail.cpp | 57 ---- .../move_convert05.fail.cpp | 61 ---- .../move_convert06.fail.cpp | 78 ------ .../move_convert07.fail.cpp | 57 ---- .../move_convert08.fail.cpp | 61 ---- .../move_convert09.fail.cpp | 78 ------ .../move_convert10.fail.cpp | 57 ---- .../move_convert11.fail.cpp | 61 ---- .../move_convert12.fail.cpp | 78 ------ .../move_convert13.fail.cpp | 57 ---- .../move_convert14.fail.cpp | 61 ---- .../move_convert15.fail.cpp | 78 ------ .../move_convert16.fail.cpp | 57 ---- .../move_convert17.fail.cpp | 61 ---- .../move_convert18.fail.cpp | 78 ------ .../unique.ptr.runtime.ctor/nullptr.pass.cpp | 46 --- .../unique.ptr.runtime.ctor/pointer01.fail.cpp | 36 --- .../unique.ptr.runtime.ctor/pointer01.pass.cpp | 63 ----- .../unique.ptr.runtime.ctor/pointer02.fail.cpp | 29 -- .../unique.ptr.runtime.ctor/pointer02.pass.cpp | 95 ------- .../unique.ptr.runtime.ctor/pointer03.fail.cpp | 23 -- .../unique.ptr.runtime.ctor/pointer04.fail.cpp | 67 ----- .../pointer_deleter01.pass.cpp | 51 ---- .../pointer_deleter02.pass.cpp | 64 ----- .../pointer_deleter03.pass.cpp | 65 ----- .../pointer_deleter04.fail.cpp | 33 --- .../pointer_deleter04.pass.cpp | 63 ----- .../pointer_deleter05.fail.cpp | 58 ---- .../unique.ptr.runtime.modifiers/release.pass.cpp | 27 -- .../unique.ptr.runtime.modifiers/reset1.pass.cpp | 50 ---- .../unique.ptr.runtime.modifiers/reset2.fail.cpp | 64 ----- .../unique.ptr.runtime.modifiers/swap.pass.cpp | 56 ---- .../dereference.fail.cpp | 23 -- .../explicit_bool.pass.cpp | 39 --- .../unique.ptr.runtime.observers/get.pass.cpp | 24 -- .../get_deleter.pass.cpp | 58 ---- .../unique.ptr.runtime.observers/index.pass.cpp | 47 ---- .../unique.ptr.runtime.observers/op_arrow.fail.cpp | 30 -- .../unique.ptr.single/pointer_type.pass.cpp | 55 ---- .../unique.ptr.single.asgn/move01.fail.cpp | 29 -- .../unique.ptr.single.asgn/move01.pass.cpp | 75 ----- .../unique.ptr.single.asgn/move02.fail.cpp | 33 --- .../unique.ptr.single.asgn/move03.fail.cpp | 33 --- .../unique.ptr.single.asgn/move04.fail.cpp | 36 --- .../unique.ptr.single.asgn/move_convert.pass.cpp | 89 ------ .../unique.ptr.single.asgn/move_convert01.fail.cpp | 42 --- .../unique.ptr.single.asgn/move_convert02.fail.cpp | 43 --- .../unique.ptr.single.asgn/move_convert03.fail.cpp | 47 ---- .../unique.ptr.single.asgn/move_convert04.fail.cpp | 43 --- .../unique.ptr.single.asgn/move_convert05.fail.cpp | 61 ---- .../unique.ptr.single.asgn/move_convert06.fail.cpp | 62 ----- .../unique.ptr.single.asgn/move_convert13.fail.cpp | 36 --- .../unique.ptr.single.asgn/null.pass.cpp | 41 --- .../unique.ptr.single.asgn/nullptr.pass.cpp | 41 --- .../unique.ptr.single.ctor/auto_pointer.pass.cpp | 80 ------ .../unique.ptr.single.ctor/auto_pointer01.fail.cpp | 67 ----- .../unique.ptr.single.ctor/auto_pointer02.fail.cpp | 61 ---- .../unique.ptr.single.ctor/default.pass.cpp | 91 ------ .../unique.ptr.single.ctor/default01.fail.cpp | 35 --- .../unique.ptr.single.ctor/default02.fail.cpp | 29 -- .../unique.ptr.single.ctor/default03.fail.cpp | 23 -- .../unique.ptr.single.ctor/move.pass.cpp | 140 ---------- .../unique.ptr.single.ctor/move01.fail.cpp | 42 --- .../unique.ptr.single.ctor/move02.fail.cpp | 42 --- .../unique.ptr.single.ctor/move03.fail.cpp | 55 ---- .../unique.ptr.single.ctor/move04.fail.cpp | 55 ---- .../unique.ptr.single.ctor/move_convert.pass.cpp | 171 ------------ .../unique.ptr.single.ctor/move_convert01.fail.cpp | 56 ---- .../unique.ptr.single.ctor/move_convert02.fail.cpp | 62 ----- .../unique.ptr.single.ctor/move_convert03.fail.cpp | 79 ------ .../unique.ptr.single.ctor/move_convert04.fail.cpp | 58 ---- .../unique.ptr.single.ctor/move_convert05.fail.cpp | 51 ---- .../unique.ptr.single.ctor/move_convert06.fail.cpp | 79 ------ .../unique.ptr.single.ctor/move_convert07.fail.cpp | 58 ---- .../unique.ptr.single.ctor/move_convert08.fail.cpp | 86 ------ .../unique.ptr.single.ctor/move_convert09.fail.cpp | 79 ------ .../unique.ptr.single.ctor/move_convert10.fail.cpp | 58 ---- .../unique.ptr.single.ctor/move_convert11.fail.cpp | 86 ------ .../unique.ptr.single.ctor/move_convert12.fail.cpp | 79 ------ .../unique.ptr.single.ctor/move_convert13.fail.cpp | 35 --- .../unique.ptr.single.ctor/nullptr.pass.cpp | 46 --- .../unique.ptr.single.ctor/pointer.pass.cpp | 163 ----------- .../unique.ptr.single.ctor/pointer01.fail.cpp | 35 --- .../unique.ptr.single.ctor/pointer02.fail.cpp | 29 -- .../unique.ptr.single.ctor/pointer03.fail.cpp | 23 -- .../pointer_deleter.pass.cpp | 123 --------- .../pointer_deleter04.fail.cpp | 30 -- .../unique.ptr.single.dtor/null.pass.cpp | 44 --- .../unique.ptr.single.modifiers/release.pass.cpp | 27 -- .../unique.ptr.single.modifiers/reset1.pass.cpp | 50 ---- .../unique.ptr.single.modifiers/reset2.pass.cpp | 66 ----- .../reset_self.pass.cpp | 29 -- .../unique.ptr.single.modifiers/swap.pass.cpp | 59 ---- .../dereference.pass.cpp | 23 -- .../explicit_bool.pass.cpp | 39 --- .../unique.ptr.single.observers/get.pass.cpp | 24 -- .../get_deleter.pass.cpp | 58 ---- .../unique.ptr.single.observers/index.fail.cpp | 47 ---- .../unique.ptr.single.observers/op_arrow.pass.cpp | 30 -- .../unique.ptr.special/cmp_nullptr.pass.cpp | 69 ----- .../unique.ptr/unique.ptr.special/eq.pass.cpp | 86 ------ .../unique.ptr/unique.ptr.special/rel.pass.cpp | 100 ------- .../unique.ptr/unique.ptr.special/swap.pass.cpp | 102 ------- .../std/utilities/smartptr/unique.ptr/README.TXT | 16 ++ .../smartptr/unique.ptr/nothing_to_do.pass.cpp | 12 + .../unique.ptr.class/pointer_type.pass.cpp | 61 ++++ .../unique.ptr.class/unique.ptr.asgn/move.pass.cpp | 119 ++++++++ .../unique.ptr.asgn/move_convert.runtime.pass.cpp | 124 +++++++++ .../unique.ptr.asgn/move_convert.single.pass.cpp | 145 ++++++++++ .../unique.ptr.class/unique.ptr.asgn/null.pass.cpp | 39 +++ .../unique.ptr.asgn/nullptr.pass.cpp | 40 +++ .../unique.ptr.ctor/auto_pointer.pass.cpp | 97 +++++++ .../unique.ptr.ctor/default.pass.cpp | 109 ++++++++ .../unique.ptr.class/unique.ptr.ctor/move.pass.cpp | 151 ++++++++++ .../unique.ptr.ctor/move_convert.runtime.pass.cpp | 80 ++++++ .../unique.ptr.ctor/move_convert.single.pass.cpp | 222 +++++++++++++++ .../unique.ptr.class/unique.ptr.ctor/null.pass.cpp | 74 +++++ .../unique.ptr.ctor/nullptr.pass.cpp | 117 ++++++++ .../unique.ptr.ctor/pointer.pass.cpp | 167 +++++++++++ .../unique.ptr.ctor/pointer_deleter.fail.cpp | 35 +++ .../unique.ptr.ctor/pointer_deleter.pass.cpp | 307 +++++++++++++++++++++ .../unique.ptr.class/unique.ptr.dtor/null.pass.cpp | 48 ++++ .../unique.ptr.modifiers/release.pass.cpp | 48 ++++ .../unique.ptr.modifiers/reset.pass.cpp | 51 ++++ .../unique.ptr.modifiers/reset.runtime.fail.cpp | 30 ++ .../unique.ptr.modifiers/reset.single.pass.cpp | 46 +++ .../unique.ptr.modifiers/reset_self.pass.cpp | 25 ++ .../unique.ptr.modifiers/swap.pass.cpp | 80 ++++++ .../dereference.runtime.fail.cpp | 24 ++ .../dereference.single.pass.cpp | 22 ++ .../unique.ptr.observers/explicit_bool.pass.cpp | 66 +++++ .../unique.ptr.observers/get.pass.cpp | 51 ++++ .../unique.ptr.observers/get_deleter.pass.cpp | 65 +++++ .../unique.ptr.observers/op_arrow.runtime.fail.cpp | 32 +++ .../unique.ptr.observers/op_arrow.single.pass.cpp | 28 ++ .../op_subscript.runtime.pass.cpp | 48 ++++ .../op_subscript.single.fail.cpp | 24 ++ .../unique.ptr.create/make_unique.array.pass.cpp | 44 +++ .../unique.ptr.create/make_unique.array1.fail.cpp | 17 ++ .../unique.ptr.create/make_unique.array2.fail.cpp | 17 ++ .../unique.ptr.create/make_unique.array3.fail.cpp | 17 ++ .../unique.ptr.create/make_unique.array4.fail.cpp | 17 ++ .../unique.ptr.create/make_unique.single.pass.cpp | 32 +++ .../unique.ptr.dltr/nothing_to_do.pass.cpp | 12 + .../unique.ptr.dltr.dflt/convert_ctor.pass.cpp | 48 ++++ .../unique.ptr.dltr.dflt/default.pass.cpp | 34 +++ .../unique.ptr.dltr.dflt/incomplete.fail.cpp | 26 ++ .../unique.ptr.dltr.dflt/void.fail.cpp | 24 ++ .../unique.ptr.dltr.dflt1/convert_ctor.fail.cpp | 32 +++ .../unique.ptr.dltr.dflt1/convert_ctor.pass.cpp | 28 ++ .../unique.ptr.dltr.dflt1/default.pass.cpp | 36 +++ .../unique.ptr.dltr.dflt1/incomplete.fail.cpp | 26 ++ .../unique.ptr.dltr.general/nothing_to_do.pass.cpp | 12 + .../unique.ptr.special/cmp_nullptr.pass.cpp | 69 +++++ .../unique.ptr/unique.ptr.special/eq.pass.cpp | 86 ++++++ .../unique.ptr/unique.ptr.special/rel.pass.cpp | 100 +++++++ .../unique.ptr/unique.ptr.special/swap.pass.cpp | 102 +++++++ 206 files changed, 3382 insertions(+), 8073 deletions(-) delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/README.TXT create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp create mode 100644 libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp (limited to 'libcxx/test/std') diff --git a/libcxx/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp deleted file mode 100644 index 30b4ecb94e1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++98, c++03, c++11 -#include -#include -#include - -// The only way to create an unique_ptr is to default construct them. - -class foo { -public: - foo () : val_(3) {} - int get () const { return val_; } -private: - int val_; - }; - -int main() -{ - { - auto p1 = std::make_unique(5); - for ( int i = 0; i < 5; ++i ) - assert ( p1[i] == 0 ); - } - - { - auto p2 = std::make_unique(5); - for ( int i = 0; i < 5; ++i ) - assert ( p2[i].size () == 0 ); - } - - { - auto p3 = std::make_unique(7); - for ( int i = 0; i < 7; ++i ) - assert ( p3[i].get () == 3 ); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp deleted file mode 100644 index 00987919413..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -int main() -{ - auto up1 = std::make_unique("error"); // doesn't compile - no bound -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp deleted file mode 100644 index cc94e9ab3aa..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -int main() -{ - auto up2 = std::make_unique(10, 20, 30, 40); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp deleted file mode 100644 index cfdc2e1d886..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -int main() -{ - auto up3 = std::make_unique(); // this is deleted -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp deleted file mode 100644 index 07aa659bd9b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -int main() -{ - auto up4 = std::make_unique(11, 22, 33, 44, 55); // deleted -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp deleted file mode 100644 index ace2e4fc713..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++98, c++03, c++11 -#include -#include -#include - -int main() -{ - { - std::unique_ptr p1 = std::make_unique(1); - assert ( *p1 == 1 ); - p1 = std::make_unique (); - assert ( *p1 == 0 ); - } - - { - std::unique_ptr p2 = std::make_unique ( "Meow!" ); - assert ( *p2 == "Meow!" ); - p2 = std::make_unique (); - assert ( *p2 == "" ); - p2 = std::make_unique ( 6, 'z' ); - assert ( *p2 == "zzzzzz" ); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp deleted file mode 100644 index 9bf794caeda..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -#include -#include - -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::default_delete d2; - std::default_delete d1 = d2; - A* p = new B; - assert(A::count == 1); - assert(B::count == 1); - d1(p); - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp deleted file mode 100644 index f686e9f01f1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - std::default_delete d; - A* p = new A; - assert(A::count == 1); - d(p); - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp deleted file mode 100644 index 255e5cd39c6..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -// Test that default_delete's operator() requires a complete type - -#include -#include - -struct A; - -int main() -{ - std::default_delete d; - A* p = 0; - d(p); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp deleted file mode 100644 index 5d1cf1ff498..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -// Test that default_delete's operator() requires a complete type - -#include -#include - -int main() -{ - std::default_delete d; - const void* p = 0; - d(p); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp deleted file mode 100644 index 41209d977b7..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -// Test that default_delete does not have a working converting constructor - -#include -#include - -struct A -{ -}; - -struct B - : public A -{ -}; - -int main() -{ - std::default_delete d2; - std::default_delete d1 = d2; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp deleted file mode 100644 index 2949d6310c5..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete[] - -// template -// default_delete(const default_delete&); -// -// This constructor shall not participate in overload resolution unless -// U(*)[] is convertible to T(*)[]. - -#include -#include - -int main() -{ - std::default_delete d1; - std::default_delete d2 = d1; - ((void)d2); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp deleted file mode 100644 index 7a409766412..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -// Test that default_delete has a working default constructor - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - std::default_delete d; - A* p = new A[3]; - assert(A::count == 3); - d(p); - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp deleted file mode 100644 index 528b10e9085..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// default_delete - -// Test that default_delete's operator() requires a complete type - -#include -#include - -struct A; - -int main() -{ - std::default_delete d; - A* p = 0; - d(p); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp deleted file mode 100644 index ed94c1a1e47..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include - -#include "test_macros.h" - -int main() -{ - std::unique_ptr s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member of 'std::__1::unique_ptr}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp deleted file mode 100644 index a29c527646b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// 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 -#include -#include - -#include "deleter_types.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr s1(new A[3]); - A* p = s1.get(); - assert(A::count == 3); - std::unique_ptr s2(new A[2]); - assert(A::count == 5); - s2 = std::move(s1); - assert(A::count == 3); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr > s1(new A[4], Deleter(5)); - A* p = s1.get(); - assert(A::count == 4); - std::unique_ptr > s2(new A[5]); - assert(A::count == 9); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 4); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter d1(5); - std::unique_ptr&> s1(new A[6], d1); - A* p = s1.get(); - assert(A::count == 6); - CDeleter d2(6); - std::unique_ptr&> s2(new A[3], d2); - assert(A::count == 9); - s2 = std::move(s1); - assert(A::count == 6); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp deleted file mode 100644 index 6e13873c2fb..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include -#include - -// 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 s(new A[3]); - std::unique_ptr s2; - s2 = s; - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp deleted file mode 100644 index 3712a279639..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include -#include - -// 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 s(new A); - A* p = s.get(); - std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp deleted file mode 100644 index 4e85e5b0fb9..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include -#include - -// 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 s(new A); - A* p = s.get(); - std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp deleted file mode 100644 index 9461958a431..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -// 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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp deleted file mode 100644 index 78caaa4f451..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include -#include -#include - -#include "deleter_types.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() -{ - { - boost::unique_ptr > s(new B); - A* p = s.get(); - boost::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp deleted file mode 100644 index b9693b86e7b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include -#include -#include - -#include "deleter_types.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 db(5); - boost::unique_ptr&> s(new B, db); - A* p = s.get(); - Deleter da(6); - boost::unique_ptr&> 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp deleted file mode 100644 index 970beb5a150..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -// 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 boost::unique_ptr s(new B); - A* p = s.get(); - boost::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp deleted file mode 100644 index 897673147f5..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include -#include -#include - -#include "deleter_types.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 boost::unique_ptr > s(new B); - A* p = s.get(); - boost::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp deleted file mode 100644 index 1081cd195bd..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include -#include -#include - -#include "deleter_types.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 db(5); - const boost::unique_ptr&> s(new B, db); - A* p = s.get(); - Deleter da(6); - boost::unique_ptr&> 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp deleted file mode 100644 index 65ee2694156..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -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() -{ - { - boost::unique_ptr s(new B); - A* p = s.get(); - boost::unique_ptr s2(new A); - assert(A::count == 2); - s2 = boost::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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp deleted file mode 100644 index 310be99f819..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -#include "deleter_types.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() -{ - { - boost::unique_ptr > s(new B); - A* p = s.get(); - boost::unique_ptr > s2(new A); - assert(A::count == 2); - s2 = (boost::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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp deleted file mode 100644 index eb48e9c94e0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include -#include -#include - -#include "deleter_types.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 db(5); - boost::unique_ptr&> s(new B, db); - A* p = s.get(); - Deleter da(6); - boost::unique_ptr&> s2(new A, da); - s2 = boost::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(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp deleted file mode 100644 index e2d7956cda6..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include - -// 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 s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp deleted file mode 100644 index 50389978e8a..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include -#include - -#include "test_macros.h" - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr p(nullptr, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#if defined(_LIBCPP_VERSION) - { - // The standard only requires the constructor accept nullptr, but libc++ - // also supports the literal 0. - std::unique_ptr p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#endif - assert(d.state() == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp deleted file mode 100644 index 30ecdded3cf..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include - -// 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 s2(new A[3]); - assert(A::count == 3); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp deleted file mode 100644 index e7ad6ad7ef3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr::pointer type - -#include -#include - -struct Deleter -{ - struct pointer {}; -}; - -int main() -{ - { - typedef std::unique_ptr P; - static_assert((std::is_same::value), ""); - } - { - typedef std::unique_ptr P; - static_assert((std::is_same::value), ""); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp deleted file mode 100644 index 43ad29623ca..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should only require default Deleter ctor - -#include -#include -#include "test_macros.h" - -#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 -_LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr; -#endif - -class Deleter { - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const { return state_; } - - void operator()(void*) {} -}; - -int main() { - { - std::unique_ptr p; - assert(p.get() == 0); - } - { - std::unique_ptr p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp deleted file mode 100644 index e4d63912723..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require default Deleter ctor - -#include -#include "test_macros.h" - -class Deleter { - Deleter() {} - -public: - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) { return *this; } - - void operator()(void*) const {} -}; - -int main() { -#if TEST_STD_VER >= 11 - // expected-error@memory:* {{call to implicitly-deleted default constructor}} - // expected-note@memory:* {{implicitly deleted because base class 'Deleter' has an inaccessible default constructor}} -#else - // expected-error@memory:* {{base class 'Deleter' has private default constructor}} -#endif - std::unique_ptr p; // expected-note {{requested here}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp deleted file mode 100644 index 82b84948f3f..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require non-reference Deleter ctor - -#include - -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr p; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp deleted file mode 100644 index 74d24fd488b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require non-pointer Deleter - -#include - -int main() -{ - std::unique_ptr p; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp deleted file mode 100644 index 38c2f1b8ab0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test default unique_ptr ctor - -// default unique_ptr ctor shouldn't require complete type - -#include -#include - -struct A; - -class Deleter { - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const { return state_; } - - void operator()(A* p); -}; - -void check(int i); - -template > -struct B { - std::unique_ptr a_; - B(); - ~B(); - - A* get() const { return a_.get(); } - D& get_deleter() { return a_.get_deleter(); } -}; - -int main() { - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A { - static int count; - A() { ++count; } - A(const A&) { ++count; } - ~A() { --count; } -}; - -int A::count = 0; - -void Deleter::operator()(A* p) { delete p; } - -void check(int i) { assert(A::count == i); } - -template -B::B() {} - -template -B::~B() {} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp deleted file mode 100644 index bc49a0e5c31..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// test move ctor. 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 s(new A[3]); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp deleted file mode 100644 index 8a1f2ce978b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include -#include -#include - -#include "deleter_types.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr s(new A[3]); - A* p = s.get(); - std::unique_ptr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - } - assert(A::count == 0); - { - std::unique_ptr > s(new A[3], Deleter(5)); - A* p = s.get(); - std::unique_ptr > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - NCDeleter d; - std::unique_ptr&> s(new A[3], d); - A* p = s.get(); - std::unique_ptr&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp deleted file mode 100644 index 8e44c78bf1e..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr s(new A[3]); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp deleted file mode 100644 index f758b083f34..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include -#include - -#include "deleter_types.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - - -std::unique_ptr -source1() -{ - return std::unique_ptr(new A[3]); -} - -void sink1(std::unique_ptr) -{ -} - -std::unique_ptr > -source2() -{ - return std::unique_ptr >(new A[3]); -} - -void sink2(std::unique_ptr >) -{ -} - -std::unique_ptr&> -source3() -{ - static NCDeleter d; - return std::unique_ptr&>(new A[3], d); -} - -void sink3(std::unique_ptr&>) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp deleted file mode 100644 index c952cf2d4e1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from lvalue - -#include -#include - -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 s(new A[3]); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp deleted file mode 100644 index 0d091ff346d..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include -#include - -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 s(new A[3]); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp deleted file mode 100644 index d175fbf93ad..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp deleted file mode 100644 index 1d3dd853f32..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp deleted file mode 100644 index 36ad75d8331..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp deleted file mode 100644 index 3a19bde9288..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp deleted file mode 100644 index 225376688aa..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp deleted file mode 100644 index fba895137b0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp deleted file mode 100644 index 24c646988f0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp deleted file mode 100644 index 2c8f2815463..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp deleted file mode 100644 index e4cbef5c056..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - const std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp deleted file mode 100644 index 73423d1b375..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp deleted file mode 100644 index a7d853ddbe9..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp deleted file mode 100644 index fdb088250b9..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - const std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp deleted file mode 100644 index d9ef8e96fe8..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp deleted file mode 100644 index 431c8bf3c6d..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp deleted file mode 100644 index 9325d07d0d0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp deleted file mode 100644 index b090e593ec6..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include -#include - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp deleted file mode 100644 index 6e214f137d1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp deleted file mode 100644 index d1c0e8a781e..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp deleted file mode 100644 index 9a8c17547bc..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include -#include - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp deleted file mode 100644 index 4c316115083..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should require default Deleter ctor - -#include - -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp deleted file mode 100644 index dab42f27741..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp deleted file mode 100644 index af7f27f73fc..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include - -// unique_ptr(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp deleted file mode 100644 index 1afb1c32ce8..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor shouldn't require complete type - -#include -#include - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template > -struct B -{ - std::unique_ptr a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(3); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(3); - B s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A[3];} - -void Deleter::operator()(A* p) {delete [] p;} - -void check(int i) -{ - assert(A::count == i); -} - -template -B::B(A* a) : a_(a) {} - -template -B::~B() {} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp deleted file mode 100644 index 31f7ce367e3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should require non-pointer Deleter - -#include - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp deleted file mode 100644 index 591144f7aa5..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should not work with derived pointers - -#include -#include - -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; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - B* p = new B[3]; - std::unique_ptr s(p); - } - { - B* p = new B[3]; - std::unique_ptr s(p); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 480dc08891c..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -#include -#include - -#include "deleter_types.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr > s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - - { // LWG#2520 says that nullptr is a valid input as well as null -#ifdef _LIBCPP_VERSION - std::unique_ptr > s1(NULL, Deleter()); -#endif - std::unique_ptr > s2(nullptr, Deleter()); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index a92fdbc1d2c..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -#include -#include - -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 set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr s(nullptr, d); - assert(s.get() == nullptr); - assert(s.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index dd27401731a..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) does not requires CopyConstructible deleter - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index 9d3f94098a0..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// XFAIL: c++98, c++03 - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, D()) should not compile - -#include - -class Deleter -{ -public: - Deleter() {} - void operator()(int* p) const {delete [] p;} -}; - -int main() -{ - int* p = nullptr; - std::unique_ptr s(p, Deleter()); // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index 02f44d35756..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) does not requires CopyConstructible deleter - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp deleted file mode 100644 index 0e03a7da07f..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter) should not work with derived pointers - -#include -#include - -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; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - B* p = new B[3]; - std::unique_ptr s(p, Deleter()); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp deleted file mode 100644 index d79a4e396ee..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test release - -#include -#include - -int main() -{ - std::unique_ptr p(new int[3]); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete [] j; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp deleted file mode 100644 index 195d877bbb7..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test reset - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr p(new A[3]); - assert(A::count == 3); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr p(new A[4]); - assert(A::count == 4); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A[5]); - assert(A::count == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp deleted file mode 100644 index bca6cb2470a..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test reset - -#include -#include - -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 p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp deleted file mode 100644 index 5e98475c7d3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test swap - -#include -#include - -#include "deleter_types.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A[3]; - std::unique_ptr > s1(p1, Deleter(1)); - A* p2 = new A[3]; - std::unique_ptr > s2(p2, Deleter(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp deleted file mode 100644 index 46ba1395bb8..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op*() - -#include -#include - -int main() -{ - std::unique_ptr p(new int(3)); - assert(*p == 3); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp deleted file mode 100644 index 9ec9b9527e8..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op*() - -#include -#include - -int main() -{ - { - std::unique_ptr p(new int [3]); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp deleted file mode 100644 index 2ae0659adc2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test get - -#include -#include - -int main() -{ - int* p = new int[3]; - std::unique_ptr s(p); - assert(s.get() == p); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp deleted file mode 100644 index 59893423f9d..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test get_deleter() - -#include -#include -#include "test_macros.h" - -struct Deleter { - Deleter() {} - - void operator()(void*) const {} - - int test() { return 5; } - int test() const { return 6; } -}; - -int main() { - { - std::unique_ptr p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr p; - assert(p.get_deleter().test() == 6); - } - { - typedef std::unique_ptr UPtr; - const Deleter d; - UPtr p(nullptr, d); - const UPtr& cp = p; - ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&); - ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&); - assert(p.get_deleter().test() == 6); - assert(cp.get_deleter().test() == 6); - } - { - typedef std::unique_ptr UPtr; - Deleter d; - UPtr p(nullptr, d); - const UPtr& cp = p; - ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&); - ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&); - assert(p.get_deleter().test() == 5); - assert(cp.get_deleter().test() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp deleted file mode 100644 index 519eae688ec..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op[](size_t) - -#include -#include - -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 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/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp deleted file mode 100644 index 1c90ba76af3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op->() - -#include -#include - -struct A -{ - int i_; - - A() : i_(7) {} -}; - -int main() -{ - std::unique_ptr p(new A); - assert(p->i_ == 7); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp deleted file mode 100644 index 380f2e100eb..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr::pointer type - -#include -#include - -#include "test_macros.h" - -struct Deleter -{ - struct pointer {}; -}; - -struct D2 { -private: - typedef void pointer; -}; - -struct D3 { - static long pointer; -}; - -int main() -{ - { - typedef std::unique_ptr P; - static_assert((std::is_same::value), ""); - } - { - typedef std::unique_ptr P; - static_assert((std::is_same::value), ""); - } -#if TEST_STD_VER >= 11 - { - typedef std::unique_ptr P; - static_assert(std::is_same::value, ""); - } - { - typedef std::unique_ptr P; - static_assert(std::is_same::value, ""); - } -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp deleted file mode 100644 index 87cfb72ad6e..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include - -#include "test_macros.h" - -// Can't copy from lvalue -int main() -{ - std::unique_ptr s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp deleted file mode 100644 index 67f4da2be6c..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// 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 -#include -#include - -#include "deleter_types.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr s1(new A); - A* p = s1.get(); - std::unique_ptr 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 > s1(new A, Deleter(5)); - A* p = s1.get(); - std::unique_ptr > 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 d1(5); - std::unique_ptr&> s1(new A, d1); - A* p = s1.get(); - CDeleter d2(6); - std::unique_ptr&> 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp deleted file mode 100644 index 9cea12b1249..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include - -#include "test_macros.h" - -// Can't copy from const lvalue - -int main() -{ - const std::unique_ptr s(new int); - std::unique_ptr s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp deleted file mode 100644 index 05a057f9bb3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from lvalue -int main() -{ - std::unique_ptr s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp deleted file mode 100644 index 24703ec9823..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from a const lvalue -int main() -{ - const std::unique_ptr s(new int); - std::unique_ptr s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp deleted file mode 100644 index 7876760fe53..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -#include "deleter_types.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; - - -template -void testAssign(APtr& aptr, BPtr& bptr) { - A* p = bptr.get(); - assert(A::count == 2); - aptr = std::move(bptr); - assert(aptr.get() == p); - assert(bptr.get() == 0); - assert(A::count == 1); - assert(B::count == 1); -} - -template -void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { - assert(lhs.get_deleter().state() == LHSState); - assert(rhs.get_deleter().state() == RHSState); -} - -int main() -{ - { - std::unique_ptr bptr(new B); - std::unique_ptr aptr(new A); - testAssign(aptr, bptr); - } - assert(A::count == 0); - assert(B::count == 0); - { - Deleter del(42); - std::unique_ptr > bptr(new B, std::move(del)); - std::unique_ptr > aptr(new A); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 0); - } - assert(A::count == 0); - assert(B::count == 0); - { - CDeleter adel(6); - CDeleter bdel(42); - std::unique_ptr&> bptr(new B, bdel); - std::unique_ptr&> aptr(new A, adel); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 42); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp deleted file mode 100644 index 816a598d9a2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include - -#include "test_macros.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr s; - std::unique_ptr s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp deleted file mode 100644 index 6e69d515239..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include - -#include "test_macros.h" -#include "deleter_types.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr > s; - std::unique_ptr > s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp deleted file mode 100644 index 1d89f99c715..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include - -#include "test_macros.h" -#include "deleter_types.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - Deleter db; - std::unique_ptr& > s(new B, db); - Deleter da; - std::unique_ptr &> s2(new A, da); -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp deleted file mode 100644 index f7de69cb750..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include - -#include "test_macros.h" -#include "deleter_types.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - const std::unique_ptr s(new B); - std::unique_ptr s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp deleted file mode 100644 index 55ebe51193d..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp deleted file mode 100644 index 657b011b367..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include -#include -#include - -#include "deleter_types.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 db(5); - const std::unique_ptr&> s(new B, db); - A* p = s.get(); - Deleter da(6); - std::unique_ptr&> 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp deleted file mode 100644 index 412648420d4..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Do not convert from an array unique_ptr - -#include -#include -#include - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr s; - std::unique_ptr s2; - s2 = std::move(s); // expected-error {{no viable overloaded '='}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp deleted file mode 100644 index e2d7956cda6..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include - -// 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 s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp deleted file mode 100644 index fb158495199..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move assignment - -#include -#include - -// 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 s2(new A); - assert(A::count == 1); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp deleted file mode 100644 index f878ce4056c..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// libc++ cannot safely provide the auto_ptr constructor without rvalue -// references. -// REQUIRES: c++11 || c++14 - -// - -// unique_ptr - -// template unique_ptr(auto_ptr&&) noexcept - -#include -#include -#include - -#include "test_macros.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() -{ - { - B* p = new B; - std::auto_ptr ap(p); - std::unique_ptr up(std::move(ap)); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr ap(p); - std::unique_ptr up; - up = std::move(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -#if TEST_STD_VER >= 11 - { - static_assert(std::is_nothrow_constructible< - std::unique_ptr, - std::auto_ptr&& - >::value, ""); - } -#endif -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp deleted file mode 100644 index 1f317c78245..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// template explicit unique_ptr(auto_ptr&); - -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() -{ - { - B* p = new B; - std::auto_ptr ap(p); - std::unique_ptr up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr ap(p); - std::unique_ptr up; - up = ap; - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp deleted file mode 100644 index 2dd5ea30049..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// template explicit unique_ptr(auto_ptr&); - -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; - -struct Deleter -{ - template - void operator()(T*) {} -}; - -int main() -{ - { - B* p = new B; - std::auto_ptr ap(p); - std::unique_ptr up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp deleted file mode 100644 index 7f589893809..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp +++ /dev/null @@ -1,91 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The default constructor works for any default constructible deleter types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Default construct unique_ptr's with various deleter types (C-1) -// 2 Default construct a unique_ptr with an incomplete element_type and -// various deleter types (C-1,2) - -#include -#include -#include "test_macros.h" - -#include "deleter_types.h" - -#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 -_LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr; -#endif - -struct IncompleteT; - -void checkNumIncompleteTypeAlive(int i); - -template > -struct StoresIncomplete { - std::unique_ptr m_ptr; - StoresIncomplete() {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -int main() -{ - { - std::unique_ptr p; - assert(p.get() == 0); - } - { - std::unique_ptr > p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 0); - p.get_deleter().set_state(5); - assert(p.get_deleter().state() == 5); - } - { - StoresIncomplete<> s; - assert(s.get() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); - { - StoresIncomplete< Deleter > s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template -StoresIncomplete::~StoresIncomplete() { } diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp deleted file mode 100644 index 2ffe1be190e..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -#include - -// default unique_ptr ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr p; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp deleted file mode 100644 index 69075014341..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -#include - -// default unique_ptr ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr p; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp deleted file mode 100644 index 78f6e73a1d5..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -#include - -// default unique_ptr ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr p; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp deleted file mode 100644 index f49702a3d91..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include -#include - -#include "deleter_types.h" - -//============================================================================= -// TESTING unique_ptr(unique_ptr&&) -// -// Concerns -// 1 The moved from pointer is empty and the new pointer stores the old value. -// 2 The only requirement on the deleter is that it is MoveConstructible -// or a reference. -// 3 The constructor works for explicitly moved values (ie std::move(x)) -// 4 The constructor works for true temporaries (ie a return value) -// -// Plan -// 1 Explicitly construct unique_ptr for various deleter types 'D'. -// check that the value and deleter have been properly moved. (C-1,2,3) -// -// 2 Use the expression 'sink(source())' to move construct a unique_ptr -// from a temporary. 'source' should return the unique_ptr by value and -// 'sink' should accept the unique_ptr by value. (C-1,2,4) - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -template -void sinkFunction(Expect) -{ -} - -typedef std::unique_ptr APtrSource1; -typedef std::unique_ptr > APtrSource2; -typedef std::unique_ptr& > APtrSource3; - -APtrSource1 source1() { - return APtrSource1 (new A); -} - -void sink1(APtrSource1 p) { - assert(p.get() != nullptr); -} - -APtrSource2 source2() { - return APtrSource2(new A, Deleter(5)); -} - -void sink2(APtrSource2 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); -} - -APtrSource3 source3() { - static NCDeleter d(5); - return APtrSource3(new A, d); -} - -void sink3(APtrSource3 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); - assert(&p.get_deleter() == &source3().get_deleter()); -} - -int main() -{ - { - typedef std::unique_ptr APtr; - APtr s(new A); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); - { - typedef Deleter MoveDel; - typedef std::unique_ptr APtr; - MoveDel d(5); - APtr s(new A, std::move(d)); - assert(d.state() == 0); - assert(s.get_deleter().state() == 5); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - typedef NCDeleter NonCopyDel; - typedef std::unique_ptr APtr; - - NonCopyDel d; - APtr s(new A, d); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - { - sink1(source1()); - assert(A::count == 0); - sink2(source2()); - assert(A::count == 0); - sink3(source3()); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp deleted file mode 100644 index 68ad589b114..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// test move ctor. 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 s(new A); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp deleted file mode 100644 index 897b889d677..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// 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; - -int main() -{ - { - const std::unique_ptr s(new A); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp deleted file mode 100644 index 7fb1a0a7481..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// test move ctor. 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 s(new A); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp deleted file mode 100644 index 671e343fd7f..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// 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 s(new A); - A* p = s.get(); - std::unique_ptr s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp deleted file mode 100644 index ada010929b1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp +++ /dev/null @@ -1,171 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// - -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// NOTE: unique_ptr does not provide converting constructors in c++03 -// XFAIL: c++98, c++03 - - - -#include -#include -#include -#include - -#include "deleter_types.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - - -template -void checkReferenceDeleter(LHS& lhs, RHS& rhs) { - typedef typename LHS::deleter_type NewDel; - static_assert(std::is_reference::value, ""); - rhs.get_deleter().set_state(42); - assert(rhs.get_deleter().state() == 42); - assert(lhs.get_deleter().state() == 42); - lhs.get_deleter().set_state(99); - assert(lhs.get_deleter().state() == 99); - assert(rhs.get_deleter().state() == 99); -} - -template -void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { - assert(lhs.get_deleter().state() == LHSVal); - assert(rhs.get_deleter().state() == RHSVal); -} - -template -void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { - assert(lhs.get() == RHSVal); - assert(rhs.get() == nullptr); - assert(A::count == 1); - assert(B::count == 1); -} - -void checkNoneAlive() { - assert(A::count == 0); - assert(B::count == 0); -} - -int main() -{ - { - typedef std::unique_ptr APtr; - typedef std::unique_ptr BPtr; - { // explicit - BPtr b(new B); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - } - checkNoneAlive(); - { // implicit - BPtr b(new B); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - } - checkNoneAlive(); - } - { // test with moveable deleters - typedef std::unique_ptr > APtr; - typedef std::unique_ptr > BPtr; - { - Deleter del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - { - Deleter del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - - } - { // test with reference deleters - typedef std::unique_ptr& > APtr; - typedef std::unique_ptr& > BPtr; - NCDeleter del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - } - { - typedef std::unique_ptr > APtr; - typedef std::unique_ptr& > BPtr; - CDeleter del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp deleted file mode 100644 index ed1fe8c2bdd..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// Can't construct 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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp deleted file mode 100644 index 3d1cb6fd0b9..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include -#include -#include - -#include "deleter_types.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 > s(new B); - A* p = s.get(); - std::unique_ptr > 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp deleted file mode 100644 index 7409199791b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp deleted file mode 100644 index 981ea706eb2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp deleted file mode 100644 index 76462dc0410..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -#include "deleter_types.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -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 > s(new B); - std::unique_ptr > s2 = s; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp deleted file mode 100644 index 5b9b12e0d60..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp deleted file mode 100644 index bef022cfc14..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp deleted file mode 100644 index 016eadcb246..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++98, c++03 - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - -template -class Deleter -{ - int state_; - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); - -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template - Deleter(Deleter&& d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template - Deleter(const Deleter& d, - typename std::enable_if::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr > s; - std::unique_ptr > s2(s); // expected-error {{no matching constructor}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp deleted file mode 100644 index a475c17547c..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - const std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp deleted file mode 100644 index f0da5efb691..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -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 s(new B); - A* p = s.get(); - std::unique_ptr 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/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp deleted file mode 100644 index 1b8bb736df2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++98, c++03 - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -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; - -template -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template - Deleter(Deleter&& d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template - Deleter(const Deleter& d, - typename std::enable_if::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr > s; - std::unique_ptr > s2 = s; // expected-error {{no viable conversion}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp deleted file mode 100644 index 095bec65669..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -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; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - const std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp deleted file mode 100644 index a4bd2cba1ce..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -// Do not convert from an array unique_ptr - -#include -#include -#include - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr s; - std::unique_ptr s2(std::move(s)); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp deleted file mode 100644 index 67a48a3e7a1..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include -#include - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp deleted file mode 100644 index da502b0b2dc..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The pointer constructor works for any default constructible deleter types. -// 2 The pointer constructor accepts pointers to derived types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Construct unique_ptr's with a pointer to 'T' and various deleter -// types (C-1) -// 2 Construct unique_ptr's with a pointer to 'D' and various deleter -// types where 'D' is derived from 'T'. (C-1,2) -// 3 Construct a unique_ptr with a pointer to 'T' and various deleter -// types where 'T' is an incomplete type (C-1,3) - -// Test unique_ptr(pointer) ctor - -#include -#include - -#include "deleter_types.h" - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -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; - - -struct IncompleteT; - -IncompleteT* getIncomplete(); -void checkNumIncompleteTypeAlive(int i); - -template > -struct StoresIncomplete { - std::unique_ptr m_ptr; - StoresIncomplete() {} - explicit StoresIncomplete(IncompleteT* ptr) : m_ptr(ptr) {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -void test_pointer() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); -} - -void test_derived() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} - -void test_incomplete() -{ - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete<> s(p); - assert(s.get() == p); - } - checkNumIncompleteTypeAlive(0); - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete< NCDeleter > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -IncompleteT* getIncomplete() { - return new IncompleteT; -} - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template -StoresIncomplete::~StoresIncomplete() { } - -int main() -{ - test_pointer(); - test_derived(); - test_incomplete(); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp deleted file mode 100644 index 1af04b2c003..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include - -// unique_ptr(pointer) ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp deleted file mode 100644 index 9b7dd8c70f2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include - -// unique_ptr(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp deleted file mode 100644 index a917d87eeed..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include - -// unique_ptr(pointer) ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr p(new int); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp deleted file mode 100644 index 929468119fa..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -//============================================================================= -// TESTING unique_ptr(pointer, deleter) -// -// Concerns: -// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. -// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. -// 3 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. -// 4 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. -// 5 unique_ptr(pointer, deleter) should work for derived pointers. -// 6 unique_ptr(pointer, deleter) should work with function pointers. -// 7 unique_ptr should work. - - -#include -#include - -#include "deleter_types.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; - -bool my_free_called = false; - -void my_free(void*) { - my_free_called = true; -} - -int main() -{ - { // MoveConstructible deleter (C-1) - A* p = new A; - assert(A::count == 1); - std::unique_ptr > s(p, Deleter(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // CopyConstructible deleter (C-2) - A* p = new A; - assert(A::count == 1); - CopyDeleter d(5); - std::unique_ptr > s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // Reference deleter (C-3) - A* p = new A; - assert(A::count == 1); - NCDeleter d(5); - std::unique_ptr&> s(p, d); - assert(s.get() == p); - assert(&s.get_deleter() == &d); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { // Const Reference deleter (C-4) - A* p = new A; - assert(A::count == 1); - NCConstDeleter d(5); - std::unique_ptr const&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - assert(&s.get_deleter() == &d); - } - assert(A::count == 0); - { // Derived pointers (C-5) - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr > s(p, Deleter(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); - { // Void and function pointers (C-6,7) - { - int i = 0; - std::unique_ptr s(&i, my_free); - assert(s.get() == &i); - assert(s.get_deleter() == my_free); - assert(!my_free_called); - } - assert(my_free_called); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index ad64b5e4ea3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// Without rvalue references it is impossible to detect when a rvalue deleter -// is given. -// XFAIL: c++98, c++03 - -// - -// unique_ptr - -// unique_ptr(pointer, D()) should not compile - -#include - -struct Deleter { - void operator()(int* p) const {delete p;} -}; - -int main() -{ - // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} - std::unique_ptr s((int*)nullptr, Deleter()); // expected-note {{requested here}} -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp deleted file mode 100644 index 064f38c5f16..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include -#include - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } - assert(d.state() == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp deleted file mode 100644 index dadd4ecbe59..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test release - -#include -#include - -int main() -{ - std::unique_ptr p(new int(3)); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete j; -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp deleted file mode 100644 index 2cf7f8b7756..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test reset - -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp deleted file mode 100644 index 2de7787b267..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test reset - -#include -#include - -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 p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - assert(i != nullptr); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp deleted file mode 100644 index 58b05efa25f..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test reset against resetting self - -#include - -struct A -{ - std::unique_ptr ptr_; - - A() : ptr_(this) {} - void reset() {ptr_.reset();} -}; - -int main() -{ - (new A)->reset(); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp deleted file mode 100644 index 68a32045819..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test swap - -#include -#include - -#include "deleter_types.h" - -struct A -{ - int state_; - static int count; - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr > s1(p1, Deleter(1)); - A* p2 = new A(2); - std::unique_ptr > s2(p2, Deleter(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp deleted file mode 100644 index 9d0cfcaaf35..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op*() - -#include -#include - -int main() -{ - std::unique_ptr p(new int(3)); - assert(*p == 3); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp deleted file mode 100644 index d5c7445b0d8..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op*() - -#include -#include - -int main() -{ - { - std::unique_ptr p(new int(3)); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp deleted file mode 100644 index 24fa6beb427..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test get - -#include -#include - -int main() -{ - int* p = new int; - std::unique_ptr s(p); - assert(s.get() == p); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp deleted file mode 100644 index 14c4d11dde3..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test get_deleter() - -#include -#include -#include "test_macros.h" - -struct Deleter { - Deleter() {} - - void operator()(void*) const {} - - int test() { return 5; } - int test() const { return 6; } -}; - -int main() { - { - std::unique_ptr p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr p; - assert(p.get_deleter().test() == 6); - } - { - typedef std::unique_ptr UPtr; - const Deleter d; - UPtr p(nullptr, d); - const UPtr& cp = p; - ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&); - ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&); - assert(p.get_deleter().test() == 6); - assert(cp.get_deleter().test() == 6); - } - { - typedef std::unique_ptr UPtr; - Deleter d; - UPtr p(nullptr, d); - const UPtr& cp = p; - ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&); - ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&); - assert(p.get_deleter().test() == 5); - assert(cp.get_deleter().test() == 5); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp deleted file mode 100644 index 21e829cbc44..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op[](size_t) - -#include -#include - -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 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/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp deleted file mode 100644 index 47de8f66ed2..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// test op->() - -#include -#include - -struct A -{ - int i_; - - A() : i_(7) {} -}; - -int main() -{ - std::unique_ptr p(new A); - assert(p->i_ == 7); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp deleted file mode 100644 index 22ae217a61d..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// shared_ptr - -// template -// bool operator==(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator==(nullptr_t, const unique_ptr& y) noexcept; -// template -// bool operator!=(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator!=(nullptr_t, const unique_ptr& y) noexcept; -// template -// bool operator<(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator<(nullptr_t, const unique_ptr& y) noexcept; -// template -// bool operator<=(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator<=(nullptr_t, const unique_ptr& y) noexcept; -// template -// bool operator>(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator>(nullptr_t, const unique_ptr& y) noexcept; -// template -// bool operator>=(const unique_ptr& x, nullptr_t) noexcept; -// template -// bool operator>=(nullptr_t, const unique_ptr& y) noexcept; - -#include -#include - -void do_nothing(int*) {} - -int main() -{ - const std::unique_ptr p1(new int(1)); - assert(!(p1 == nullptr)); - assert(!(nullptr == p1)); - assert(!(p1 < nullptr)); - assert( (nullptr < p1)); - assert(!(p1 <= nullptr)); - assert( (nullptr <= p1)); - assert( (p1 > nullptr)); - assert(!(nullptr > p1)); - assert( (p1 >= nullptr)); - assert(!(nullptr >= p1)); - - const std::unique_ptr p2; - assert( (p2 == nullptr)); - assert( (nullptr == p2)); - assert(!(p2 < nullptr)); - assert(!(nullptr < p2)); - assert( (p2 <= nullptr)); - assert( (nullptr <= p2)); - assert(!(p2 > nullptr)); - assert(!(nullptr > p2)); - assert( (p2 >= nullptr)); - assert( (nullptr >= p2)); -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp deleted file mode 100644 index 88a1e04ba4e..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// template -// bool -// operator==(const unique_ptr& x, const unique_ptr& y); - -// template -// bool -// operator!=(const unique_ptr& x, const unique_ptr& y); - -#include -#include - -#include "deleter_types.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 > p1(new A); - const std::unique_ptr > p2(new A); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr > p1(new A); - const std::unique_ptr > p2(new B); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr > p1(new A[3]); - const std::unique_ptr > p2(new A[3]); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr > p1(new A[3]); - const std::unique_ptr > p2(new B[3]); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr > p1; - const std::unique_ptr > p2; - assert(p1 == p2); - assert(!(p1 != p2)); - } - { - const std::unique_ptr > p1; - const std::unique_ptr > p2; - assert(p1 == p2); - assert(!(p1 != p2)); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp deleted file mode 100644 index 94ae89ba92b..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// template -// bool -// operator< (const unique_ptr& x, const unique_ptr& y); - -// template -// bool -// operator> (const unique_ptr& x, const unique_ptr& y); - -// template -// bool -// operator<=(const unique_ptr& x, const unique_ptr& y); - -// template -// bool -// operator>=(const unique_ptr& x, const unique_ptr& y); - -#include -#include - -#include "deleter_types.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 > p1(new A); - const std::unique_ptr > p2(new A); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr > p1(new A); - const std::unique_ptr > p2(new B); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr > p1(new A[3]); - const std::unique_ptr > p2(new A[3]); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr > p1(new A[3]); - const std::unique_ptr > p2(new B[3]); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr > p1; - const std::unique_ptr > p2; - assert((p1 < p2) == (p1 > p2)); - assert((p1 < p2) == !(p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr > p1; - const std::unique_ptr > p2; - assert((p1 < p2) == (p1 > p2)); - assert((p1 < p2) == !(p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } -} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp deleted file mode 100644 index 7ac0ba490e9..00000000000 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test swap - -#include -#include - -#include "test_macros.h" -#include "deleter_types.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -template -struct NonSwappableDeleter { - explicit NonSwappableDeleter(int) {} - NonSwappableDeleter& operator=(NonSwappableDeleter const&) { return *this; } - void operator()(T*) const {} -private: - NonSwappableDeleter(NonSwappableDeleter const&); - -}; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr > s1(p1, Deleter(1)); - A* p2 = new A(2); - std::unique_ptr > s2(p2, Deleter(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - swap(s1, s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); - { - A* p1 = new A[3]; - std::unique_ptr > s1(p1, Deleter(1)); - A* p2 = new A[3]; - std::unique_ptr > s2(p2, Deleter(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - swap(s1, s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -#if TEST_STD_VER >= 11 - { - // test that unique_ptr's specialized swap is disabled when the deleter - // is non-swappable. Instead we should pick up the generic swap(T, T) - // and perform 3 move constructions. - typedef NonSwappableDeleter D; - D d(42); - int x = 42; - int y = 43; - std::unique_ptr p(&x, d); - std::unique_ptr p2(&y, d); - std::swap(p, p2); - } -#endif -} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/README.TXT b/libcxx/test/std/utilities/smartptr/unique.ptr/README.TXT new file mode 100644 index 00000000000..20f77f61827 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/README.TXT @@ -0,0 +1,16 @@ +Test Naming and Directory Structure +=================================== + +The directory structure for the unique_ptr class templates differs from the +normal test directory naming conventions (e.g. matching the stable name in the standard). + +Instead of having a [unique.ptr.single] and [unique.ptr.runtime] directory, +each containing their own tests, a single directory, "unique.ptr.class", +contains both sets of tests. + +This allows the common behavior of the two unique_ptr specializations to be +tested in the same place without duplication. + +Tests specific to [unique.ptr.single] have the suffix ".single.pass.cpp" +and those specific to [unique.ptr.runtime] are named "*.runtime.pass.cpp". +Tests for both specializations are named normally. diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp new file mode 100644 index 00000000000..54c2cf16ecc --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr::pointer type + +#include +#include + +#include "test_macros.h" + +struct Deleter { + struct pointer {}; +}; + +struct D2 { +private: + typedef void pointer; +}; + +struct D3 { + static long pointer; +}; + +template +void test_basic() { + typedef typename std::conditional::type VT; + { + typedef std::unique_ptr P; + static_assert((std::is_same::value), ""); + } + { + typedef std::unique_ptr P; + static_assert((std::is_same::value), + ""); + } +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr P; + static_assert(std::is_same::value, ""); + } + { + typedef std::unique_ptr P; + static_assert(std::is_same::value, ""); + } +#endif +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp new file mode 100644 index 00000000000..378421866bc --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp @@ -0,0 +1,119 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// + +// 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 +#include +#include + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +struct GenericDeleter { + void operator()(void*) const; +}; + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr s1(newValue(expect_alive)); + A* p = s1.get(); + std::unique_ptr s2(newValue(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(A::count == expect_alive); + assert(s2.get() == p); + assert(s1.get() == 0); + } + assert(A::count == 0); + { + std::unique_ptr > s1(newValue(expect_alive), + Deleter(5)); + A* p = s1.get(); + std::unique_ptr > s2(newValue(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s1.get_deleter().state() == 0); + } + assert(A::count == 0); + { + CDeleter d1(5); + std::unique_ptr&> s1(newValue(expect_alive), d1); + A* p = s1.get(); + CDeleter d2(6); + std::unique_ptr&> s2(newValue(expect_alive), d2); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(d1.state() == 5); + assert(d2.state() == 5); + } + assert(A::count == 0); +} + +template +void test_sfinae() { + typedef typename std::conditional::type VT; + { + typedef std::unique_ptr U; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(std::is_assignable::value, ""); + } + { + typedef std::unique_ptr U; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(std::is_assignable::value, ""); + } + { + typedef std::unique_ptr&> U; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(std::is_assignable::value, ""); + } + { + typedef std::unique_ptr&> U; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(std::is_assignable::value, ""); + } +} + +int main() { + { + test_basic(); + test_sfinae(); + } + { + test_basic(); + test_sfinae(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp new file mode 100644 index 00000000000..9b946a733fe --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#include "unique_ptr_test_helper.h" + +template +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter; // non-copyable deleters + using DAC = NCConvertingDeleter; // non-copyable deleters + + using DB = NCConvertingDeleter; + using UA = std::unique_ptr; + using UAC = std::unique_ptr; + using UB = std::unique_ptr; + using UAD = std::unique_ptr; + using UACD = std::unique_ptr; + + using UBD = std::unique_ptr; + { // cannot move from an lvalue + static_assert(std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } +} + +int main() { + test_sfinae(); + // FIXME: add tests +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp new file mode 100644 index 00000000000..3f2ea422dab --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp @@ -0,0 +1,145 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter; // non-copyable deleters + using DB = NCConvertingDeleter; + using UA = std::unique_ptr; + using UB = std::unique_ptr; + using UAD = std::unique_ptr; + using UBD = std::unique_ptr; + { // cannot move from an lvalue + static_assert(std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } +} + +int main() { + test_sfinae(); + { + std::unique_ptr bptr(new B); + std::unique_ptr aptr(new A); + testAssign(aptr, bptr); + } + assert(A::count == 0); + assert(B::count == 0); + { + Deleter del(42); + std::unique_ptr > bptr(new B, std::move(del)); + std::unique_ptr > aptr(new A); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 0); + } + assert(A::count == 0); + assert(B::count == 0); + { + CDeleter adel(6); + CDeleter bdel(42); + std::unique_ptr&> bptr(new B, bdel); + std::unique_ptr&> aptr(new A, adel); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 42); + } + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp new file mode 100644 index 00000000000..165d48a1caa --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +#include "unique_ptr_test_helper.h" + +// test assignment from null +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr s2(newValue(expect_alive)); + assert(A::count == expect_alive); + s2 = NULL; + assert(A::count == 0); + assert(s2.get() == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp new file mode 100644 index 00000000000..e1e2e32e23c --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +#include "unique_ptr_test_helper.h" + +// test assignment from null + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr s2(newValue(expect_alive)); + assert(A::count == expect_alive); + s2 = nullptr; + assert(A::count == 0); + assert(s2.get() == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp new file mode 100644 index 00000000000..7d5e9bca63c --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// libc++ cannot safely provide the auto_ptr constructor without rvalue +// references. +// REQUIRES: c++11 || c++14 + +// + +// unique_ptr + +// template unique_ptr(auto_ptr&&) noexcept + +#include +#include +#include + +#include "test_macros.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; + +struct C {}; + +struct Deleter { + void operator()(void*) {} +}; + +void test_sfinae() { + { + // the auto_ptr constructor should be disable with a non-default deleter. + using AP = std::auto_ptr; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { + // the auto_ptr constructor should be disabled when the pointer types are incompatible. + using AP = std::auto_ptr; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } +} + +int main() { + { + B* p = new B; + std::auto_ptr ap(p); + std::unique_ptr up(std::move(ap)); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + std::auto_ptr ap(p); + std::unique_ptr up; + up = std::move(ap); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +#if TEST_STD_VER >= 11 + { + static_assert(std::is_nothrow_constructible, + std::auto_ptr&&>::value, + ""); + } +#endif + test_sfinae(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp new file mode 100644 index 00000000000..03bd6c5737a --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp @@ -0,0 +1,109 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr() +// +// Concerns: +// 1 The default constructor works for any default constructible deleter types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Default construct unique_ptr's with various deleter types (C-1) +// 2 Default construct a unique_ptr with an incomplete element_type and +// various deleter types (C-1,2) + +#include +#include +#include "test_macros.h" + +#include "test_macros.h" +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +#include "test_workarounds.h" // For TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES + +#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 +_LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr_single; +_LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr_runtime; +#endif + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template +void test_sfinae() { +#if TEST_STD_VER >= 11 && !defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr; + static_assert(!std::is_default_constructible::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter; + using U1 = std::unique_ptr; + using U2 = std::unique_ptr; + using U3 = std::unique_ptr; + static_assert(!std::is_default_constructible::value, ""); + static_assert(!std::is_default_constructible::value, ""); + static_assert(!std::is_default_constructible::value, ""); + } +#endif +} + +template +void test_basic() { +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr; + using U2 = std::unique_ptr >; + static_assert(std::is_nothrow_default_constructible::value, ""); + static_assert(std::is_nothrow_default_constructible::value, ""); + } +#endif + { + std::unique_ptr p; + assert(p.get() == 0); + } + { + std::unique_ptr > p; + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + p.get_deleter().set_state(5); + assert(p.get_deleter().state() == 5); + } +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + doIncompleteTypeTest(0); + doIncompleteTypeTest >(0); +} { + doIncompleteTypeTest(0); + doIncompleteTypeTest >(0); +}) + +int main() { + { + test_sfinae(); + test_basic(); + } + { + test_sfinae(); + test_basic(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp new file mode 100644 index 00000000000..8f52fe5ee97 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp @@ -0,0 +1,151 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include +#include + +#include "test_macros.h" +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +//============================================================================= +// TESTING unique_ptr(unique_ptr&&) +// +// Concerns +// 1 The moved from pointer is empty and the new pointer stores the old value. +// 2 The only requirement on the deleter is that it is MoveConstructible +// or a reference. +// 3 The constructor works for explicitly moved values (ie std::move(x)) +// 4 The constructor works for true temporaries (ie a return value) +// +// Plan +// 1 Explicitly construct unique_ptr for various deleter types 'D'. +// check that the value and deleter have been properly moved. (C-1,2,3) +// +// 2 Use the expression 'sink(source())' to move construct a unique_ptr +// from a temporary. 'source' should return the unique_ptr by value and +// 'sink' should accept the unique_ptr by value. (C-1,2,4) + +template +std::unique_ptr source1() { + return std::unique_ptr(newValue(1)); +} + +template +std::unique_ptr > source2() { + return std::unique_ptr >(newValue(1), Deleter(5)); +} + +template +std::unique_ptr&> source3() { + static NCDeleter d(5); + return std::unique_ptr&>(newValue(1), d); +} + +template +void sink1(std::unique_ptr p) { + assert(p.get() != nullptr); +} + +template +void sink2(std::unique_ptr > p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); +} + +template +void sink3(std::unique_ptr&> p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); + assert(&p.get_deleter() == &source3().get_deleter()); +} + +template +void test_sfinae() { + typedef std::unique_ptr U; + { // Ensure unique_ptr is non-copyable + static_assert((!std::is_constructible::value), ""); + static_assert((!std::is_constructible::value), ""); + } +} + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + typedef std::unique_ptr APtr; + APtr s(newValue(expect_alive)); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + } + assert(A::count == 0); + { + typedef Deleter MoveDel; + typedef std::unique_ptr APtr; + MoveDel d(5); + APtr s(newValue(expect_alive), std::move(d)); + assert(d.state() == 0); + assert(s.get_deleter().state() == 5); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + { + typedef NCDeleter NonCopyDel; + typedef std::unique_ptr APtr; + + NonCopyDel d; + APtr s(newValue(expect_alive), d); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + d.set_state(6); + assert(s2.get_deleter().state() == d.state()); + assert(s.get_deleter().state() == d.state()); + } + assert(A::count == 0); + { + sink1(source1()); + assert(A::count == 0); + sink2(source2()); + assert(A::count == 0); + sink3(source3()); + assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + { + test_basic(); + test_sfinae(); + } + { + test_basic(); + test_sfinae(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp new file mode 100644 index 00000000000..b259049fcfe --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template +struct GenericDeleter { + void operator()(void*) const {} +}; + +template +struct GenericConvertingDeleter { + template + GenericConvertingDeleter(GenericConvertingDeleter) {} + void operator()(void*) const {} +}; + +void test_sfinae() { + { // Disallow copying + using U1 = std::unique_ptr >; + using U2 = std::unique_ptr >; + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { // Disallow illegal qualified conversions + using U1 = std::unique_ptr; + using U2 = std::unique_ptr; + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr; + using UB = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr >; + using UB = std::unique_ptr >; + static_assert(!std::is_constructible::value, ""); + } + { // Disallow invalid deleter initialization + using U1 = std::unique_ptr >; + using U2 = std::unique_ptr >; + static_assert(!std::is_constructible::value, ""); + } + { // Disallow reference deleters with different qualifiers + using U1 = std::unique_ptr&>; + using U2 = std::unique_ptr&>; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { + using U1 = std::unique_ptr; + using U2 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +} + +int main() { test_sfinae(); } diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp new file mode 100644 index 00000000000..e2e5cc67da9 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp @@ -0,0 +1,222 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// + +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +// NOTE: unique_ptr does not provide converting constructors in c++03 +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +// test converting move ctor. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. +// Explicit version + +template +void checkReferenceDeleter(LHS& lhs, RHS& rhs) { + typedef typename LHS::deleter_type NewDel; + static_assert(std::is_reference::value, ""); + rhs.get_deleter().set_state(42); + assert(rhs.get_deleter().state() == 42); + assert(lhs.get_deleter().state() == 42); + lhs.get_deleter().set_state(99); + assert(lhs.get_deleter().state() == 99); + assert(rhs.get_deleter().state() == 99); +} + +template +void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { + assert(lhs.get_deleter().state() == LHSVal); + assert(rhs.get_deleter().state() == RHSVal); +} + +template +void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { + assert(lhs.get() == RHSVal); + assert(rhs.get() == nullptr); + assert(A::count == 1); + assert(B::count == 1); +} + +void checkNoneAlive() { + assert(A::count == 0); + assert(B::count == 0); +} + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +template +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template + NCConvertingDeleter(NCConvertingDeleter&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter; // non-copyable deleters + using DB = NCConvertingDeleter; + using UA = std::unique_ptr; + using UB = std::unique_ptr; + using UAD = std::unique_ptr; + using UBD = std::unique_ptr; + { // cannot move from an lvalue + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { // cannot move-convert from unique_ptr + using UA1 = std::unique_ptr; + using UA2 = std::unique_ptr; + using UB1 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +} + +int main() { + { + typedef std::unique_ptr APtr; + typedef std::unique_ptr BPtr; + { // explicit + BPtr b(new B); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + } + checkNoneAlive(); + { // implicit + BPtr b(new B); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + } + checkNoneAlive(); + } + { // test with moveable deleters + typedef std::unique_ptr > APtr; + typedef std::unique_ptr > BPtr; + { + Deleter del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + { + Deleter del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + } + { // test with reference deleters + typedef std::unique_ptr&> APtr; + typedef std::unique_ptr&> BPtr; + NCDeleter del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + } + { + typedef std::unique_ptr > APtr; + typedef std::unique_ptr&> BPtr; + CDeleter del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + } + test_sfinae(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp new file mode 100644 index 00000000000..8bc8a57c1c8 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// + +// unique_ptr + +// FIXME(EricWF): This test contains tests for constructing a unique_ptr from NULL. +// The behavior demonstrated in this test is not meant to be standard; It simply +// tests the current status quo in libc++. + +#include +#include + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template +void test_pointer_ctor() { + { + std::unique_ptr p(0); + assert(p.get() == 0); + } + { + std::unique_ptr > p(0); + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + } +} + +template +void test_pointer_deleter_ctor() { + { + std::default_delete d; + std::unique_ptr p(0, d); + assert(p.get() == 0); + } + { + std::unique_ptr > p(0, Deleter(5)); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCDeleter d(5); + std::unique_ptr&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCConstDeleter d(5); + std::unique_ptr const&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } +} + +int main() { + { + // test_pointer_ctor(); + test_pointer_deleter_ctor(); + } + { + test_pointer_ctor(); + test_pointer_deleter_ctor(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp new file mode 100644 index 00000000000..8e4ee7bb118 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp @@ -0,0 +1,117 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// unique_ptr(nullptr_t); + +#include +#include + +#include "test_macros.h" +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +#include "test_workarounds.h" // For TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES + +// default unique_ptr ctor should only require default Deleter ctor +class DefaultDeleter { + int state_; + + DefaultDeleter(DefaultDeleter&); + DefaultDeleter& operator=(DefaultDeleter&); + +public: + DefaultDeleter() : state_(5) {} + + int state() const { return state_; } + + void operator()(void*) {} +}; + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template +void test_basic() { + { + std::unique_ptr p(nullptr); + assert(p.get() == 0); + } + { + std::unique_ptr p(nullptr); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr; + using U2 = std::unique_ptr >; + static_assert(std::is_nothrow_constructible::value, + ""); + static_assert(std::is_nothrow_constructible::value, + ""); + } +#endif +} + +template +void test_sfinae() { +#if TEST_STD_VER >= 11 && !defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter; + using U1 = std::unique_ptr; + using U2 = std::unique_ptr; + using U3 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest >(0, + nullptr); + } + checkNumIncompleteTypeAlive(0); + { doIncompleteTypeTest(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest >( + 0, nullptr); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_basic(); + test_sfinae(); + } + { + test_basic(); + test_sfinae(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp new file mode 100644 index 00000000000..3ae77d384b2 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp @@ -0,0 +1,167 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr(pointer) +// +// Concerns: +// 1 The pointer constructor works for any default constructible deleter types. +// 2 The pointer constructor accepts pointers to derived types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Construct unique_ptr's with a pointer to 'T' and various deleter +// types (C-1) +// 2 Construct unique_ptr's with a pointer to 'D' and various deleter +// types where 'D' is derived from 'T'. (C-1,2) +// 3 Construct a unique_ptr with a pointer to 'T' and various deleter +// types where 'T' is an incomplete type (C-1,3) + +// Test unique_ptr(pointer) ctor + +#include +#include + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +#include "test_workarounds.h" // For TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES + +// unique_ptr(pointer) ctor should only require default Deleter ctor + +template +void test_pointer() { + typedef typename std::conditional::type ValueT; + const int expect_alive = IsArray ? 5 : 1; +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr; + using U2 = std::unique_ptr >; + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + } +#endif + { + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); +} + +void test_derived() { + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr s(p); + assert(s.get() == p); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + assert(B::count == 0); +} + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; +#endif + +template +void test_sfinae() { +#if TEST_STD_VER >= 11 && !defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter; + using U1 = std::unique_ptr; + using U2 = std::unique_ptr; + using U3 = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +#endif +} + +static void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resolution when + // a base <-> derived conversion would occur. + using UA = std::unique_ptr; + using UAD = std::unique_ptr; + using UAC = std::unique_ptr; + using UB = std::unique_ptr; + using UBD = std::unique_ptr; + using UBC = std::unique_ptr; + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(1, getNewIncomplete()); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest >( + 1, getNewIncomplete()); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_pointer(); + test_derived(); + test_sfinae(); + } + { + test_pointer(); + test_sfinae(); + test_sfinae_runtime(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp new file mode 100644 index 00000000000..4ef4f1463b0 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// Without rvalue references it is impossible to detect when a rvalue deleter +// is given. +// XFAIL: c++98, c++03 + +// + +// unique_ptr + +// unique_ptr(pointer, D()) should not compile + +#include + +#include "test_workarounds.h" + +struct Deleter { + void operator()(int* p) const { delete p; } +}; + +int main() { +#if defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) +// expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} +#else +// expected-error@+2 {{call to deleted constructor of 'std::unique_ptr}} +#endif + std::unique_ptr s((int*)nullptr, Deleter()); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp new file mode 100644 index 00000000000..601751eb335 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp @@ -0,0 +1,307 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING unique_ptr(pointer, deleter) +// +// Concerns: +// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. +// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. +// 3 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. +// 4 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. +// 5 unique_ptr(pointer, deleter) should work for derived pointers. +// 6 unique_ptr(pointer, deleter) should work with function pointers. +// 7 unique_ptr should work. + +#include +#include + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +#include "test_workarounds.h" // For TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES + +bool my_free_called = false; + +void my_free(void*) { my_free_called = true; } + +#if TEST_STD_VER >= 11 +struct DeleterBase { + void operator()(void*) const {} +}; +struct CopyOnlyDeleter : DeleterBase { + CopyOnlyDeleter() = default; + CopyOnlyDeleter(CopyOnlyDeleter const&) = default; + CopyOnlyDeleter(CopyOnlyDeleter&&) = delete; +}; +struct MoveOnlyDeleter : DeleterBase { + MoveOnlyDeleter() = default; + MoveOnlyDeleter(MoveOnlyDeleter&&) = default; +}; +struct NoCopyMoveDeleter : DeleterBase { + NoCopyMoveDeleter() = default; + NoCopyMoveDeleter(NoCopyMoveDeleter const&) = delete; +}; +#endif + +template +void test_sfinae() { +#if TEST_STD_VER >= 11 && !defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) + typedef typename std::conditional::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr; + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +#endif +} + +template +void test_noexcept() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr; + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr; + static_assert(std::is_nothrow_constructible::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(std::is_nothrow_constructible::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + } +#endif +} + +void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 && !defined(TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES) + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr; + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(!std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr; + static_assert(std::is_constructible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + static_assert(!std::is_constructible::value, ""); + } +#endif +} + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { // MoveConstructible deleter (C-1) + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr > s(p, Deleter(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // CopyConstructible deleter (C-2) + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + CopyDeleter d(5); + std::unique_ptr > s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // Reference deleter (C-3) + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + NCDeleter d(5); + std::unique_ptr&> s(p, d); + assert(s.get() == p); + assert(&s.get_deleter() == &d); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 6); + } + assert(A::count == 0); + { // Const Reference deleter (C-4) + A* p = newValue(expect_alive); + assert(A::count == expect_alive); + NCConstDeleter d(5); + std::unique_ptr const&> s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + assert(&s.get_deleter() == &d); + } + assert(A::count == 0); + { // Void and function pointers (C-6,7) + typedef typename std::conditional::type VT2; + my_free_called = false; + { + int i = 0; + std::unique_ptr s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +void test_basic_single() { + assert(A::count == 0); + assert(B::count == 0); + { // Derived pointers (C-5) + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr > s(p, Deleter(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + assert(B::count == 0); + { // Void and function pointers (C-6,7) + my_free_called = false; + { + int i = 0; + std::unique_ptr s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +int main() { + { + test_basic(); + test_basic_single(); + test_sfinae(); + test_noexcept(); + } + { + test_basic(); + test_sfinae(); + test_sfinae_runtime(); + test_noexcept(); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp new file mode 100644 index 00000000000..5507e7e34ee --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// The deleter is not called if get() == 0 + +#include +#include + +class Deleter { + int state_; + + Deleter(Deleter&); + Deleter& operator=(Deleter&); + +public: + Deleter() : state_(0) {} + + int state() const { return state_; } + + void operator()(void*) { ++state_; } +}; + +template +void test_basic() { + Deleter d; + assert(d.state() == 0); + { + std::unique_ptr p(0, d); + assert(p.get() == 0); + assert(&p.get_deleter() == &d); + } + assert(d.state() == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp new file mode 100644 index 00000000000..581340f6104 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test release + +#include +#include + +#include "unique_ptr_test_helper.h" + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 3 : 1; + { + std::unique_ptr p(newValue(expect_alive)); + assert(A::count == expect_alive); + A* ap = p.get(); + A* a = p.release(); + assert(A::count == expect_alive); + assert(p.get() == nullptr); + assert(ap == a); + assert(a != nullptr); + + if (IsArray) + delete[] a; + else + delete a; + + assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp new file mode 100644 index 00000000000..302023b6077 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +#include "unique_ptr_test_helper.h" + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 3 : 1; + { + std::unique_ptr p(newValue(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + p.reset(); + assert(A::count == 0); + assert(p.get() == 0); + } + assert(A::count == 0); + { + std::unique_ptr p(newValue(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + A* new_value = newValue(expect_alive); + assert(A::count == (expect_alive * 2)); + p.reset(new_value); + assert(A::count == expect_alive); + } + assert(A::count == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp new file mode 100644 index 00000000000..0d067b9abff --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +#include "unique_ptr_test_helper.h" + +int main() { + { + std::unique_ptr p; + p.reset(static_cast(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } + { + std::unique_ptr p; + p.reset(static_cast(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp new file mode 100644 index 00000000000..8f2a69913dd --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +#include "unique_ptr_test_helper.h" + +int main() { + { + std::unique_ptr p(new A); + assert(A::count == 1); + assert(B::count == 0); + A* i = p.get(); + assert(i != nullptr); + p.reset(new B); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); + { + std::unique_ptr p(new B); + assert(A::count == 1); + assert(B::count == 1); + A* i = p.get(); + assert(i != nullptr); + p.reset(new B); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp new file mode 100644 index 00000000000..f838661c53f --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset against resetting self + +#include + +struct A { + std::unique_ptr ptr_; + + A() : ptr_(this) {} + void reset() { ptr_.reset(); } +}; + +int main() { (new A)->reset(); } diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp new file mode 100644 index 00000000000..0316398061e --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test swap + +#include +#include + +#include "unique_ptr_test_helper.h" + +struct TT { + int state_; + static int count; + TT() : state_(-1) { ++count; } + explicit TT(int i) : state_(i) { ++count; } + TT(const TT& a) : state_(a.state_) { ++count; } + TT& operator=(const TT& a) { + state_ = a.state_; + return *this; + } + ~TT() { --count; } + + friend bool operator==(const TT& x, const TT& y) { + return x.state_ == y.state_; + } +}; + +int TT::count = 0; + +template +typename std::remove_all_extents::type* newValueInit(int size, + int new_value) { + typedef typename std::remove_all_extents::type VT; + VT* p = newValue(size); + for (int i = 0; i < size; ++i) + (p + i)->state_ = new_value; + return p; +} + +template +void test_basic() { + typedef typename std::conditional::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + TT* p1 = newValueInit(expect_alive, 1); + std::unique_ptr > s1(p1, Deleter(1)); + TT* p2 = newValueInit(expect_alive, 2); + std::unique_ptr > s2(p2, Deleter(2)); + assert(s1.get() == p1); + assert(*s1.get() == TT(1)); + assert(s1.get_deleter().state() == 1); + assert(s2.get() == p2); + assert(*s2.get() == TT(2)); + assert(s2.get_deleter().state() == 2); + s1.swap(s2); + assert(s1.get() == p2); + assert(*s1.get() == TT(2)); + assert(s1.get_deleter().state() == 2); + assert(s2.get() == p1); + assert(*s2.get() == TT(1)); + assert(s2.get_deleter().state() == 1); + assert(TT::count == (expect_alive * 2)); + } + assert(TT::count == 0); +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp new file mode 100644 index 00000000000..b05fb71cdc6 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() { + std::unique_ptr p(new int(3)); + const std::unique_ptr& cp = p; + (void)(*p); // expected-error {{indirection requires pointer operand ('std::unique_ptr' invalid)}} + (void)(*cp); // expected-error {{indirection requires pointer operand ('const std::unique_ptr' invalid)}} +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp new file mode 100644 index 00000000000..b2d3da48dae --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() { + std::unique_ptr p(new int(3)); + assert(*p == 3); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp new file mode 100644 index 00000000000..9a6d6c65fa8 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template +void doTest(UPtr& p, bool ExpectTrue) { + if (p) + assert(ExpectTrue); + else + assert(!ExpectTrue); + + if (!p) + assert(!ExpectTrue); + else + assert(ExpectTrue); +} + +template +void test_basic() { + typedef typename std::conditional::type VT; + typedef std::unique_ptr U; + { + static_assert((std::is_constructible::value), ""); + static_assert((std::is_constructible::value), ""); + } +#if TEST_STD_VER >= 11 + { + static_assert(!std::is_convertible::value, ""); + static_assert(!std::is_convertible::value, ""); + } +#endif + { + U p(newValue(1)); + U const& cp = p; + doTest(p, true); + doTest(cp, true); + } + { + U p; + const U& cp = p; + doTest(p, false); + doTest(cp, false); + } +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp new file mode 100644 index 00000000000..518e31cf948 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get + +#include +#include + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template +void test_basic() { + typedef typename std::conditional::type VT; + typedef const VT CVT; + { + typedef std::unique_ptr U; + int* p = newValue(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), int*); + ASSERT_SAME_TYPE(decltype(sc.get()), int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } + { + typedef std::unique_ptr U; + const int* p = newValue(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), const int*); + ASSERT_SAME_TYPE(decltype(sc.get()), const int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp new file mode 100644 index 00000000000..6a00d14a2ca --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get_deleter() + +#include +#include +#include "test_macros.h" + +struct Deleter { + Deleter() {} + + void operator()(void*) const {} + + int test() { return 5; } + int test() const { return 6; } +}; + +template +void test_basic() { + typedef typename std::conditional::type VT; + { + std::unique_ptr p; + assert(p.get_deleter().test() == 5); + } + { + const std::unique_ptr p; + assert(p.get_deleter().test() == 6); + } + { + typedef std::unique_ptr UPtr; + const Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&); + assert(p.get_deleter().test() == 6); + assert(cp.get_deleter().test() == 6); + } + { + typedef std::unique_ptr UPtr; + Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&); + assert(p.get_deleter().test() == 5); + assert(cp.get_deleter().test() == 5); + } +} + +int main() { + test_basic(); + test_basic(); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp new file mode 100644 index 00000000000..d66af054ce6 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op->() + +#include +#include + +struct V { + int member; +}; + +int main() { + std::unique_ptr p; + std::unique_ptr const& cp = p; + + p->member; // expected-error {{member reference type 'std::unique_ptr' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} + + cp->member; // expected-error {{member reference type 'const std::unique_ptr' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp new file mode 100644 index 00000000000..8bed9dda2ea --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op->() + +#include +#include + +struct A { + int i_; + + A() : i_(7) {} +}; + +int main() { + std::unique_ptr p(new A); + assert(p->i_ == 7); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp new file mode 100644 index 00000000000..b47c35afb4f --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op[](size_t) + +#include +#include + +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 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/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp new file mode 100644 index 00000000000..529749da67e --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op[](size_t) + +#include +#include + +int main() { + std::unique_ptr p(new int[3]); + std::unique_ptr const& cp = p; + p[0]; // expected-error {{type 'std::unique_ptr' does not provide a subscript operator}} + cp[1]; // expected-error {{type 'const std::unique_ptr' does not provide a subscript operator}} +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp new file mode 100644 index 00000000000..30b4ecb94e1 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03, c++11 +#include +#include +#include + +// The only way to create an unique_ptr is to default construct them. + +class foo { +public: + foo () : val_(3) {} + int get () const { return val_; } +private: + int val_; + }; + +int main() +{ + { + auto p1 = std::make_unique(5); + for ( int i = 0; i < 5; ++i ) + assert ( p1[i] == 0 ); + } + + { + auto p2 = std::make_unique(5); + for ( int i = 0; i < 5; ++i ) + assert ( p2[i].size () == 0 ); + } + + { + auto p3 = std::make_unique(7); + for ( int i = 0; i < 7; ++i ) + assert ( p3[i].get () == 3 ); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp new file mode 100644 index 00000000000..00987919413 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +int main() +{ + auto up1 = std::make_unique("error"); // doesn't compile - no bound +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp new file mode 100644 index 00000000000..cc94e9ab3aa --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +int main() +{ + auto up2 = std::make_unique(10, 20, 30, 40); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp new file mode 100644 index 00000000000..cfdc2e1d886 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +int main() +{ + auto up3 = std::make_unique(); // this is deleted +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp new file mode 100644 index 00000000000..07aa659bd9b --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +int main() +{ + auto up4 = std::make_unique(11, 22, 33, 44, 55); // deleted +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp new file mode 100644 index 00000000000..ace2e4fc713 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03, c++11 +#include +#include +#include + +int main() +{ + { + std::unique_ptr p1 = std::make_unique(1); + assert ( *p1 == 1 ); + p1 = std::make_unique (); + assert ( *p1 == 0 ); + } + + { + std::unique_ptr p2 = std::make_unique ( "Meow!" ); + assert ( *p2 == "Meow!" ); + p2 = std::make_unique (); + assert ( *p2 == "" ); + p2 = std::make_unique ( 6, 'z' ); + assert ( *p2 == "zzzzzz" ); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp new file mode 100644 index 00000000000..9bf794caeda --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +#include +#include + +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::default_delete d2; + std::default_delete d1 = d2; + A* p = new B; + assert(A::count == 1); + assert(B::count == 1); + d1(p); + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp new file mode 100644 index 00000000000..f686e9f01f1 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + std::default_delete d; + A* p = new A; + assert(A::count == 1); + d(p); + assert(A::count == 0); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp new file mode 100644 index 00000000000..255e5cd39c6 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +struct A; + +int main() +{ + std::default_delete d; + A* p = 0; + d(p); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp new file mode 100644 index 00000000000..5d1cf1ff498 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +int main() +{ + std::default_delete d; + const void* p = 0; + d(p); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp new file mode 100644 index 00000000000..41209d977b7 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete does not have a working converting constructor + +#include +#include + +struct A +{ +}; + +struct B + : public A +{ +}; + +int main() +{ + std::default_delete d2; + std::default_delete d1 = d2; +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp new file mode 100644 index 00000000000..2949d6310c5 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete[] + +// template +// default_delete(const default_delete&); +// +// This constructor shall not participate in overload resolution unless +// U(*)[] is convertible to T(*)[]. + +#include +#include + +int main() +{ + std::default_delete d1; + std::default_delete d2 = d1; + ((void)d2); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp new file mode 100644 index 00000000000..7a409766412 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete has a working default constructor + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + std::default_delete d; + A* p = new A[3]; + assert(A::count == 3); + d(p); + assert(A::count == 0); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp new file mode 100644 index 00000000000..528b10e9085 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +struct A; + +int main() +{ + std::default_delete d; + A* p = 0; + d(p); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp new file mode 100644 index 00000000000..22ae217a61d --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// bool operator==(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator==(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator!=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator!=(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator<(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator<(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator<=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator<=(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator>(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator>(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator>=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator>=(nullptr_t, const unique_ptr& y) noexcept; + +#include +#include + +void do_nothing(int*) {} + +int main() +{ + const std::unique_ptr p1(new int(1)); + assert(!(p1 == nullptr)); + assert(!(nullptr == p1)); + assert(!(p1 < nullptr)); + assert( (nullptr < p1)); + assert(!(p1 <= nullptr)); + assert( (nullptr <= p1)); + assert( (p1 > nullptr)); + assert(!(nullptr > p1)); + assert( (p1 >= nullptr)); + assert(!(nullptr >= p1)); + + const std::unique_ptr p2; + assert( (p2 == nullptr)); + assert( (nullptr == p2)); + assert(!(p2 < nullptr)); + assert(!(nullptr < p2)); + assert( (p2 <= nullptr)); + assert( (nullptr <= p2)); + assert(!(p2 > nullptr)); + assert(!(nullptr > p2)); + assert( (p2 >= nullptr)); + assert( (nullptr >= p2)); +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp new file mode 100644 index 00000000000..88a1e04ba4e --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// template +// bool +// operator==(const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator!=(const unique_ptr& x, const unique_ptr& y); + +#include +#include + +#include "deleter_types.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 > p1(new A); + const std::unique_ptr > p2(new A); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A); + const std::unique_ptr > p2(new B); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new A[3]); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new B[3]); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert(p1 == p2); + assert(!(p1 != p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert(p1 == p2); + assert(!(p1 != p2)); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp new file mode 100644 index 00000000000..94ae89ba92b --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp @@ -0,0 +1,100 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// template +// bool +// operator< (const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator> (const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator<=(const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator>=(const unique_ptr& x, const unique_ptr& y); + +#include +#include + +#include "deleter_types.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 > p1(new A); + const std::unique_ptr > p2(new A); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A); + const std::unique_ptr > p2(new B); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new A[3]); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new B[3]); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert((p1 < p2) == (p1 > p2)); + assert((p1 < p2) == !(p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert((p1 < p2) == (p1 > p2)); + assert((p1 < p2) == !(p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } +} diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp new file mode 100644 index 00000000000..7ac0ba490e9 --- /dev/null +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test swap + +#include +#include + +#include "test_macros.h" +#include "deleter_types.h" + +struct A +{ + int state_; + static int count; + A() : state_(0) {++count;} + explicit A(int i) : state_(i) {++count;} + A(const A& a) : state_(a.state_) {++count;} + A& operator=(const A& a) {state_ = a.state_; return *this;} + ~A() {--count;} + + friend bool operator==(const A& x, const A& y) + {return x.state_ == y.state_;} +}; + +int A::count = 0; + +template +struct NonSwappableDeleter { + explicit NonSwappableDeleter(int) {} + NonSwappableDeleter& operator=(NonSwappableDeleter const&) { return *this; } + void operator()(T*) const {} +private: + NonSwappableDeleter(NonSwappableDeleter const&); + +}; + +int main() +{ + { + A* p1 = new A(1); + std::unique_ptr > s1(p1, Deleter(1)); + A* p2 = new A(2); + std::unique_ptr > s2(p2, Deleter(2)); + assert(s1.get() == p1); + assert(*s1 == A(1)); + assert(s1.get_deleter().state() == 1); + assert(s2.get() == p2); + assert(*s2 == A(2)); + assert(s2.get_deleter().state() == 2); + swap(s1, s2); + assert(s1.get() == p2); + assert(*s1 == A(2)); + assert(s1.get_deleter().state() == 2); + assert(s2.get() == p1); + assert(*s2 == A(1)); + assert(s2.get_deleter().state() == 1); + assert(A::count == 2); + } + assert(A::count == 0); + { + A* p1 = new A[3]; + std::unique_ptr > s1(p1, Deleter(1)); + A* p2 = new A[3]; + std::unique_ptr > s2(p2, Deleter(2)); + assert(s1.get() == p1); + assert(s1.get_deleter().state() == 1); + assert(s2.get() == p2); + assert(s2.get_deleter().state() == 2); + swap(s1, s2); + assert(s1.get() == p2); + assert(s1.get_deleter().state() == 2); + assert(s2.get() == p1); + assert(s2.get_deleter().state() == 1); + assert(A::count == 6); + } + assert(A::count == 0); +#if TEST_STD_VER >= 11 + { + // test that unique_ptr's specialized swap is disabled when the deleter + // is non-swappable. Instead we should pick up the generic swap(T, T) + // and perform 3 move constructions. + typedef NonSwappableDeleter D; + D d(42); + int x = 42; + int y = 43; + std::unique_ptr p(&x, d); + std::unique_ptr p2(&y, d); + std::swap(p, p2); + } +#endif +} -- cgit v1.2.3