From 42a739b357db75cb9c827a4c0b2d25d84f009899 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 4 Feb 2005 16:39:44 +0000 Subject: [PATCH] Fixed nonportable elision assumption. [SVN r27093] --- test/weak_ptr_test.cpp | 115 +++++++++++++++++++++++++++++++++-------- 1 file changed, 93 insertions(+), 22 deletions(-) diff --git a/test/weak_ptr_test.cpp b/test/weak_ptr_test.cpp index 347cd01..7213794 100644 --- a/test/weak_ptr_test.cpp +++ b/test/weak_ptr_test.cpp @@ -17,7 +17,7 @@ // // weak_ptr_test.cpp // -// Copyright (c) 2002, 2003 Peter Dimov +// Copyright (c) 2002-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -500,7 +500,7 @@ void test() namespace n_assignment { -template void copy_assignment(boost::shared_ptr sp) +template void copy_assignment(boost::shared_ptr & sp) { BOOST_TEST(sp.unique()); @@ -611,7 +611,7 @@ void conversion_assignment() } } -template void shared_ptr_assignment(boost::shared_ptr sp, T * = 0) +template void shared_ptr_assignment(boost::shared_ptr & sp, T * = 0) { BOOST_TEST(sp.unique()); @@ -644,18 +644,62 @@ template void shared_ptr_assignment(boost::shared_ptr sp, T void test() { - copy_assignment(boost::shared_ptr(new int)); - copy_assignment(boost::shared_ptr(new X)); - copy_assignment(boost::shared_ptr(new int)); - copy_assignment(create_incomplete()); + { + boost::shared_ptr p( new int ); + copy_assignment( p ); + } + + { + boost::shared_ptr p( new X ); + copy_assignment( p ); + } + + { + boost::shared_ptr p( new int ); + copy_assignment( p ); + } + + { + boost::shared_ptr p = create_incomplete(); + copy_assignment( p ); + } + conversion_assignment(); - shared_ptr_assignment(boost::shared_ptr(new int)); - shared_ptr_assignment(boost::shared_ptr(new int)); - shared_ptr_assignment(boost::shared_ptr(new X)); - shared_ptr_assignment(boost::shared_ptr(new X)); - shared_ptr_assignment(boost::shared_ptr(new int)); - shared_ptr_assignment(create_incomplete()); - shared_ptr_assignment(create_incomplete()); + + { + boost::shared_ptr p( new int ); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p( new int ); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p( new X ); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p( new X ); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p( new int ); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p = create_incomplete(); + shared_ptr_assignment( p ); + } + + { + boost::shared_ptr p = create_incomplete(); + shared_ptr_assignment( p ); + } } } // namespace n_assignment @@ -663,7 +707,7 @@ void test() namespace n_reset { -template void test2(boost::shared_ptr sp, T * = 0) +template void test2( boost::shared_ptr & sp, T * = 0 ) { BOOST_TEST(sp.unique()); @@ -697,13 +741,40 @@ template void test2(boost::shared_ptr sp, T * = 0) void test() { - test2(boost::shared_ptr(new int)); - test2(boost::shared_ptr(new int)); - test2(boost::shared_ptr(new X)); - test2(boost::shared_ptr(new X)); - test2(boost::shared_ptr(new int)); - test2(create_incomplete()); - test2(create_incomplete()); + { + boost::shared_ptr p( new int ); + test2( p ); + } + + { + boost::shared_ptr p( new int ); + test2( p ); + } + + { + boost::shared_ptr p( new X ); + test2( p ); + } + + { + boost::shared_ptr p( new X ); + test2( p ); + } + + { + boost::shared_ptr p( new int ); + test2( p ); + } + + { + boost::shared_ptr p = create_incomplete(); + test2( p ); + } + + { + boost::shared_ptr p = create_incomplete(); + test2( p ); + } } } // namespace n_reset