Add one more intrusive_ptr test case.

This commit is contained in:
Peter Dimov
2013-12-26 18:05:52 +02:00
parent 73153d5797
commit 4e46cb0609

View File

@@ -332,9 +332,26 @@ void test()
} }
{ {
boost::intrusive_ptr<X> px(new X); boost::intrusive_ptr<X> px;
X* detached = px.detach(); X* detached = px.detach();
BOOST_TEST(detached->use_count() == 1); BOOST_TEST( px.get() == 0 );
BOOST_TEST( detached == 0 );
}
{
X * p = new X;
BOOST_TEST( p->use_count() == 0 );
boost::intrusive_ptr<X> px( p );
BOOST_TEST( px.get() == p );
BOOST_TEST( px->use_count() == 1 );
X * detached = px.detach();
BOOST_TEST( px.get() == 0 );
BOOST_TEST( detached == p );
BOOST_TEST( detached->use_count() == 1 );
delete detached; delete detached;
} }
} }