diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp @@ -120,5 +120,25 @@ assert(B::count == 0); assert(A::count == 0); +#if TEST_STD_VER > 14 + { + std::shared_ptr p1(new A[8]); + A* ptr = p1.get(); + assert(A::count == 8); + { + std::shared_ptr p2; + p2 = p1; + assert(A::count == 8); + assert(p2.use_count() == 2); + assert(p1.use_count() == 2); + assert(p1.get() == p2.get()); + assert(p2.get() == ptr); + } + assert(p1.use_count() == 1); + assert(A::count == 8); + } + assert(A::count == 0); +#endif + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include "test_macros.h" @@ -122,5 +123,25 @@ assert(B::count == 0); assert(A::count == 0); +#if TEST_STD_VER > 14 + { + std::shared_ptr p1(new A[8]); + A* ptr = p1.get(); + assert(A::count == 8); + { + std::shared_ptr p2; + p2 = std::move(p1); + assert(A::count == 8); + assert(p2.use_count() == 1); + assert(p1.use_count() == 0); + assert(p1.get() == nullptr); + assert(p2.get() == ptr); + } + assert(p1.use_count() == 0); + assert(A::count == 0); + } + assert(A::count == 0); +#endif + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp @@ -59,6 +59,13 @@ assert(A::count == 8); } assert(A::count == 0); + + { + std::shared_ptr pA(new A[8]); + assert(pA.use_count() == 1); + assert(A::count == 8); + } + assert(A::count == 0); #endif return 0; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp @@ -133,4 +133,22 @@ private_delete_arr_op*>::value, ""); } #endif + +#if TEST_STD_VER > 14 + { + std::shared_ptr p1(new A[8]); + assert(p1.use_count() == 1); + assert(A::count == 8); + { + std::shared_ptr p2(p1); + assert(A::count == 8); + assert(p2.use_count() == 2); + assert(p1.use_count() == 2); + assert(p1.get() == p2.get()); + } + assert(p1.use_count() == 1); + assert(A::count == 8); + } + assert(A::count == 0); +#endif } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include "test_macros.h" @@ -96,7 +97,7 @@ assert(B::count == 0); assert(A::count == 0); { - std::shared_ptr pB(pA); + std::shared_ptr pB(std::move(pA)); assert(B::count == 0); assert(A::count == 0); assert(pB.use_count() == 0); @@ -110,5 +111,23 @@ assert(B::count == 0); assert(A::count == 0); +#if TEST_STD_VER > 14 + { + std::shared_ptr p1; + assert(p1.use_count() == 0); + assert(A::count == 0); + { + std::shared_ptr p2(p1); + assert(A::count == 0); + assert(p2.use_count() == 0); + assert(p1.use_count() == 0); + assert(p1.get() == p2.get()); + } + assert(p1.use_count() == 0); + assert(A::count == 0); + } + assert(A::count == 0); +#endif + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp @@ -63,5 +63,17 @@ } assert(A::count == 0); +#if TEST_STD_VER > 14 + { + std::shared_ptr p; + A* ptr = new A[8]; + p.reset(ptr); + assert(A::count == 8); + assert(p.use_count() == 1); + assert(p.get() == ptr); + } + assert(A::count == 0); +#endif + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp @@ -81,5 +81,17 @@ assert(test_deleter::count == 0); assert(test_deleter::dealloc_count == 2); +#if TEST_STD_VER > 14 + { + std::shared_ptr p; + A* ptr = new A[8]; + p.reset(ptr, CDeleter()); + assert(A::count == 8); + assert(p.use_count() == 1); + assert(p.get() == ptr); + } + assert(A::count == 0); +#endif + return 0; } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp @@ -90,5 +90,17 @@ assert(test_allocator::count == 0); assert(test_allocator::alloc_count == 0); +#if TEST_STD_VER > 14 + { + std::shared_ptr p; + A* ptr = new A[8]; + p.reset(ptr, CDeleter(), test_allocator()); + assert(A::count == 8); + assert(p.use_count() == 1); + assert(p.get() == ptr); + } + assert(A::count == 0); +#endif + return 0; }