Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-04-26 09:39:53


Author: pdimov
Date: 2008-04-26 09:39:52 EDT (Sat, 26 Apr 2008)
New Revision: 44775
URL: http://svn.boost.org/trac/boost/changeset/44775

Log:
Added a few more tests.
Text files modified:
   trunk/libs/smart_ptr/test/esft_regtest.cpp | 37 +++++++++++++++++++++++++++++++++++++
   1 files changed, 37 insertions(+), 0 deletions(-)

Modified: trunk/libs/smart_ptr/test/esft_regtest.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/esft_regtest.cpp (original)
+++ trunk/libs/smart_ptr/test/esft_regtest.cpp 2008-04-26 09:39:52 EDT (Sat, 26 Apr 2008)
@@ -160,6 +160,7 @@
     V * p = new W;
     boost::shared_ptr<void> pv( p );
     BOOST_TEST( pv.get() == p );
+ BOOST_TEST( pv.use_count() == 1 );
 }
 
 struct null_deleter
@@ -171,6 +172,41 @@
 {
     boost::shared_ptr<V> pv( new V );
     boost::shared_ptr<V> pv2( pv.get(), null_deleter() );
+ BOOST_TEST( pv2.get() == pv.get() );
+ BOOST_TEST( pv2.use_count() == 1 );
+}
+
+void test5()
+{
+ V v;
+
+ boost::shared_ptr<V> p1( &v, null_deleter() );
+ BOOST_TEST( p1.get() == &v );
+ BOOST_TEST( p1.use_count() == 1 );
+
+ try
+ {
+ p1->shared_from_this();
+ }
+ catch( ... )
+ {
+ BOOST_ERROR( "p1->shared_from_this() failed" );
+ }
+
+ p1.reset();
+
+ boost::shared_ptr<V> p2( &v, null_deleter() );
+ BOOST_TEST( p2.get() == &v );
+ BOOST_TEST( p2.use_count() == 1 );
+
+ try
+ {
+ p2->shared_from_this();
+ }
+ catch( ... )
+ {
+ BOOST_ERROR( "p2->shared_from_this() failed" );
+ }
 }
 
 int main()
@@ -179,6 +215,7 @@
     test2();
     test3();
     test4();
+ test5();
 
     return boost::report_errors();
 }


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