From 595b14f0de6d02ad375673921ebd8f7d2452526e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Mon, 16 Mar 2015 14:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Test/SharedPtrTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TinySTL/Test/SharedPtrTest.cpp b/TinySTL/Test/SharedPtrTest.cpp index 219be6d..dc8fe18 100644 --- a/TinySTL/Test/SharedPtrTest.cpp +++ b/TinySTL/Test/SharedPtrTest.cpp @@ -13,12 +13,14 @@ namespace TinySTL{ auto sp3(sp2); assert(sp3.use_count() == 2); - - auto sp4 = sp2; - assert(sp4.use_count() == 3); + { + auto sp4 = sp2; + assert(sp4.use_count() == 3 && sp3.use_count() == sp4.use_count()); - assert(sp2.get() == sp3.get() && sp2.get() == sp4.get()); - assert(sp2 == sp3 && !(sp2 != sp4)); + assert(sp2.get() == sp3.get() && sp2.get() == sp4.get()); + assert(sp2 == sp3 && !(sp2 != sp4)); + } + assert(sp3.use_count() == 2); shared_ptr sp5(new string("hello")); assert(*sp5 == "hello");