$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: fmhess_at_[hidden]
Date: 2008-03-23 10:51:41
Author: fmhess
Date: 2008-03-23 10:51:40 EDT (Sun, 23 Mar 2008)
New Revision: 43804
URL: http://svn.boost.org/trac/boost/changeset/43804
Log:
Added a little more test code for new enable_shared_from_this behavior.
Text files modified: 
   trunk/libs/smart_ptr/test/esft_constructor_test.cpp |    25 +++++++++++++++++++++++++               
   1 files changed, 25 insertions(+), 0 deletions(-)
Modified: trunk/libs/smart_ptr/test/esft_constructor_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/esft_constructor_test.cpp	(original)
+++ trunk/libs/smart_ptr/test/esft_constructor_test.cpp	2008-03-23 10:51:40 EDT (Sun, 23 Mar 2008)
@@ -75,6 +75,9 @@
     return a && !(a < b) && !(b < a);
 }
 
+struct Y: public boost::enable_shared_from_this<Y>
+{};
+
 int main()
 {
     BOOST_TEST( X::instances == 0 );
@@ -121,6 +124,14 @@
         early_px.reset();
         BOOST_TEST( px.use_count() == 1 );
         BOOST_TEST( X::instances == 1 );
+        px.reset();
+        try
+        {
+            x.shared_from_this();
+            BOOST_ERROR("x did not throw bad_weak_ptr");
+        }
+        catch( const boost::bad_weak_ptr &err)
+        {}
     }
 
     BOOST_TEST( X::instances == 0 );
@@ -140,5 +151,19 @@
 
     BOOST_TEST( X::instances == 0 );
 
+    {
+        boost::shared_ptr<Y> px(new Y());
+        Y y(*px);
+        px.reset();
+        try
+        {
+            y.shared_from_this();
+        }
+        catch( const boost::bad_weak_ptr &err)
+        {
+            BOOST_ERROR("y threw bad_weak_ptr");
+        }
+    }
+    
     return boost::report_errors();
 }