Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81776 - trunk/libs/smart_ptr/test
From: pdimov_at_[hidden]
Date: 2012-12-07 17:42:57


Author: pdimov
Date: 2012-12-07 17:42:56 EST (Fri, 07 Dec 2012)
New Revision: 81776
URL: http://svn.boost.org/trac/boost/changeset/81776

Log:
Add more unique_ptr tests.
Text files modified:
   trunk/libs/smart_ptr/test/sp_unique_ptr_test.cpp | 63 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 63 insertions(+), 0 deletions(-)

Modified: trunk/libs/smart_ptr/test/sp_unique_ptr_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/sp_unique_ptr_test.cpp (original)
+++ trunk/libs/smart_ptr/test/sp_unique_ptr_test.cpp 2012-12-07 17:42:56 EST (Fri, 07 Dec 2012)
@@ -95,6 +95,60 @@
         p2 = std::unique_ptr<X>( new X );
         BOOST_TEST( X::instances == 1 );
 
+ p2 = std::unique_ptr<X>( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ p2.reset();
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ BOOST_TEST( X::instances == 0 );
+
+ std::unique_ptr<X> p( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ boost::shared_ptr<X const> p2( std::move( p ) );
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( p.get() == 0 );
+
+ boost::shared_ptr<X const> p3 = p2->shared_from_this();
+ BOOST_TEST( p2 == p3 );
+ BOOST_TEST( !(p2 < p3) && !(p3 < p2) );
+
+ p2.reset();
+ p3.reset();
+ BOOST_TEST( X::instances == 0 );
+
+ p2 = std::unique_ptr<X>( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ p2 = std::unique_ptr<X>( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ p2.reset();
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ BOOST_TEST( X::instances == 0 );
+
+ std::unique_ptr<X> p( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ boost::shared_ptr<void> p2( std::move( p ) );
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( p.get() == 0 );
+
+ p2.reset();
+ BOOST_TEST( X::instances == 0 );
+
+ p2 = std::unique_ptr<X>( new X );
+ BOOST_TEST( X::instances == 1 );
+
+ p2 = std::unique_ptr<X>( new X );
+ BOOST_TEST( X::instances == 1 );
+
         p2.reset();
         BOOST_TEST( X::instances == 0 );
     }
@@ -115,6 +169,9 @@
         p2 = std::unique_ptr<Y, YD>( new Y, YD() );
         BOOST_TEST( Y::instances == 1 );
 
+ p2 = std::unique_ptr<Y, YD>( new Y, YD() );
+ BOOST_TEST( Y::instances == 1 );
+
         p2.reset();
         BOOST_TEST( Y::instances == 0 );
     }
@@ -137,6 +194,9 @@
         p2 = std::unique_ptr<Y, YD&>( new Y, yd );
         BOOST_TEST( Y::instances == 1 );
 
+ p2 = std::unique_ptr<Y, YD&>( new Y, yd );
+ BOOST_TEST( Y::instances == 1 );
+
         p2.reset();
         BOOST_TEST( Y::instances == 0 );
     }
@@ -159,6 +219,9 @@
         p2 = std::unique_ptr<Y, YD const&>( new Y, yd );
         BOOST_TEST( Y::instances == 1 );
 
+ p2 = std::unique_ptr<Y, YD const&>( new Y, yd );
+ BOOST_TEST( Y::instances == 1 );
+
         p2.reset();
         BOOST_TEST( Y::instances == 0 );
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk