From 0dc0969cd0a732760f0aa79942a04e0eaef297c4 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:03:23 +0000 Subject: Vendor import of libc++ trunk r300422: https://llvm.org/svn/llvm-project/libcxx/trunk@300422 --- .../unique.ptr.asgn/nullptr.pass.cpp | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp (limited to 'test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp') diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp new file mode 100644 index 0000000000000..e1e2e32e23c48 --- /dev/null +++ b/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(); +} -- cgit v1.2.3