forked from boostorg/smart_ptr
Improve abi_test
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_DISABLE_THREADS)
|
||||
@ -22,10 +23,21 @@ BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" )
|
||||
|
||||
void abi_test_1( boost::shared_ptr<void> & p )
|
||||
{
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
p.reset();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 0 );
|
||||
}
|
||||
|
||||
boost::shared_ptr<void> abi_test_2( boost::shared_ptr<void> const & p )
|
||||
{
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
boost::shared_ptr<void> abi_test_3()
|
||||
{
|
||||
return boost::shared_ptr<void>( static_cast<int*>( 0 ) );
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" )
|
||||
|
||||
void abi_test_1( boost::shared_ptr<void> & p );
|
||||
boost::shared_ptr<void> abi_test_2( boost::shared_ptr<void> const & p );
|
||||
boost::shared_ptr<void> abi_test_3();
|
||||
|
||||
static int deleter_called;
|
||||
|
||||
@ -67,5 +68,15 @@ int main()
|
||||
BOOST_TEST_EQ( deleter_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<void> p = abi_test_3();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
p.reset();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user