2000-07-07 16:04:40 +00:00
|
|
|
// smart pointer test program ----------------------------------------------//
|
|
|
|
|
2004-08-10 10:34:20 +00:00
|
|
|
// Copyright Beman Dawes 1998, 1999. Distributed under the Boost
|
|
|
|
// Software License, Version 1.0. (See accompanying file
|
|
|
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
2003-09-12 17:09:29 +00:00
|
|
|
|
|
|
|
// See http://www.boost.org/libs/smart_ptr for documentation.
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
// Revision History
|
2001-05-24 18:42:25 +00:00
|
|
|
// 24 May 01 use Boost test library for error detection, reporting, add tests
|
|
|
|
// for operations on incomplete types (Beman Dawes)
|
2000-07-07 16:04:40 +00:00
|
|
|
// 29 Nov 99 added std::swap and associative container tests (Darin Adler)
|
|
|
|
// 25 Sep 99 added swap tests
|
|
|
|
// 20 Jul 99 header name changed to .hpp
|
|
|
|
// 20 Apr 99 additional error tests added.
|
|
|
|
|
2018-01-23 21:45:59 +02:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
2003-09-12 17:09:29 +00:00
|
|
|
|
2011-03-22 23:05:48 +00:00
|
|
|
#include <boost/smart_ptr.hpp>
|
2024-09-24 18:25:13 +03:00
|
|
|
#include <boost/config.hpp>
|
2002-02-02 18:36:12 +00:00
|
|
|
|
2020-01-01 08:29:47 -05:00
|
|
|
#include <boost/core/lightweight_test.hpp>
|
2002-02-02 18:36:12 +00:00
|
|
|
|
2000-07-07 16:04:40 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <set>
|
2007-11-25 18:38:02 +00:00
|
|
|
#include <string.h>
|
2000-07-07 16:04:40 +00:00
|
|
|
|
2001-05-24 18:42:25 +00:00
|
|
|
class Incomplete;
|
|
|
|
|
|
|
|
Incomplete * get_ptr( boost::shared_ptr<Incomplete>& incomplete )
|
|
|
|
{
|
|
|
|
return incomplete.get();
|
|
|
|
}
|
2000-07-07 16:04:40 +00:00
|
|
|
|
2002-10-23 13:55:18 +00:00
|
|
|
template<class T>
|
2001-05-24 18:42:25 +00:00
|
|
|
void ck( const T* v1, T v2 ) { BOOST_TEST( *v1 == v2 ); }
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
int UDT_use_count; // independent of pointer maintained counts
|
|
|
|
}
|
|
|
|
|
|
|
|
// user defined type -------------------------------------------------------//
|
|
|
|
|
|
|
|
class UDT {
|
|
|
|
long value_;
|
|
|
|
public:
|
|
|
|
explicit UDT( long value=0 ) : value_(value) { ++UDT_use_count; }
|
|
|
|
~UDT() {
|
|
|
|
--UDT_use_count;
|
2007-11-25 18:38:02 +00:00
|
|
|
std::cout << "UDT with value " << value_ << " being destroyed\n";
|
2000-07-07 16:04:40 +00:00
|
|
|
}
|
|
|
|
long value() const { return value_; }
|
|
|
|
void value( long v ) { value_ = v;; }
|
|
|
|
}; // UDT
|
|
|
|
|
2001-05-24 18:42:25 +00:00
|
|
|
// tests on incomplete types -----------------------------------------------//
|
|
|
|
|
|
|
|
// Certain smart pointer operations are specified to work on incomplete types,
|
|
|
|
// and some uses depend upon this feature. These tests verify compilation
|
|
|
|
// only - the functions aren't actually invoked.
|
|
|
|
|
|
|
|
class Incomplete;
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
Incomplete * check_incomplete( boost::scoped_ptr<Incomplete>& incomplete )
|
2001-05-24 18:42:25 +00:00
|
|
|
{
|
|
|
|
return incomplete.get();
|
|
|
|
}
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
Incomplete * check_incomplete( boost::shared_ptr<Incomplete>& incomplete,
|
|
|
|
boost::shared_ptr<Incomplete>& i2 )
|
2001-05-24 18:42:25 +00:00
|
|
|
{
|
|
|
|
incomplete.swap(i2);
|
2007-11-25 18:38:02 +00:00
|
|
|
std::cout << incomplete.use_count() << ' ' << incomplete.unique() << '\n';
|
2001-05-24 18:42:25 +00:00
|
|
|
return incomplete.get();
|
|
|
|
}
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
// This isn't a very systematic test; it just hits some of the basics.
|
|
|
|
|
2002-08-16 16:41:16 +00:00
|
|
|
void test()
|
|
|
|
{
|
|
|
|
BOOST_TEST( UDT_use_count == 0 ); // reality check
|
|
|
|
|
|
|
|
// test scoped_ptr with a built-in type
|
|
|
|
long * lp = new long;
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::scoped_ptr<long> sp ( lp );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( sp.get() == lp );
|
|
|
|
BOOST_TEST( lp == sp.get() );
|
|
|
|
BOOST_TEST( &*sp == lp );
|
|
|
|
|
|
|
|
*sp = 1234568901L;
|
|
|
|
BOOST_TEST( *sp == 1234568901L );
|
|
|
|
BOOST_TEST( *lp == 1234568901L );
|
|
|
|
ck( static_cast<long*>(sp.get()), 1234568901L );
|
|
|
|
ck( lp, *sp );
|
|
|
|
|
|
|
|
sp.reset();
|
|
|
|
BOOST_TEST( sp.get() == 0 );
|
|
|
|
|
|
|
|
// test scoped_ptr with a user defined type
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::scoped_ptr<UDT> udt_sp ( new UDT( 999888777 ) );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( udt_sp->value() == 999888777 );
|
|
|
|
udt_sp.reset();
|
|
|
|
udt_sp.reset( new UDT( 111222333 ) );
|
|
|
|
BOOST_TEST( udt_sp->value() == 111222333 );
|
|
|
|
udt_sp.reset( new UDT( 333222111 ) );
|
|
|
|
BOOST_TEST( udt_sp->value() == 333222111 );
|
|
|
|
|
|
|
|
// test scoped_array with a build-in type
|
|
|
|
char * sap = new char [ 100 ];
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::scoped_array<char> sa ( sap );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( sa.get() == sap );
|
|
|
|
BOOST_TEST( sap == sa.get() );
|
|
|
|
|
|
|
|
strcpy( sa.get(), "Hot Dog with mustard and relish" );
|
|
|
|
BOOST_TEST( strcmp( sa.get(), "Hot Dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( strcmp( sap, "Hot Dog with mustard and relish" ) == 0 );
|
|
|
|
|
|
|
|
BOOST_TEST( sa[0] == 'H' );
|
|
|
|
BOOST_TEST( sa[30] == 'h' );
|
|
|
|
|
|
|
|
sa[0] = 'N';
|
|
|
|
sa[4] = 'd';
|
|
|
|
BOOST_TEST( strcmp( sap, "Not dog with mustard and relish" ) == 0 );
|
|
|
|
|
|
|
|
sa.reset();
|
|
|
|
BOOST_TEST( sa.get() == 0 );
|
|
|
|
|
|
|
|
// test shared_ptr with a built-in type
|
|
|
|
int * ip = new int;
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<int> cp ( ip );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( ip == cp.get() );
|
|
|
|
BOOST_TEST( cp.use_count() == 1 );
|
|
|
|
|
|
|
|
*cp = 54321;
|
|
|
|
BOOST_TEST( *cp == 54321 );
|
|
|
|
BOOST_TEST( *ip == 54321 );
|
|
|
|
ck( static_cast<int*>(cp.get()), 54321 );
|
|
|
|
ck( static_cast<int*>(ip), *cp );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<int> cp2 ( cp );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( ip == cp2.get() );
|
|
|
|
BOOST_TEST( cp.use_count() == 2 );
|
|
|
|
BOOST_TEST( cp2.use_count() == 2 );
|
|
|
|
|
|
|
|
BOOST_TEST( *cp == 54321 );
|
|
|
|
BOOST_TEST( *cp2 == 54321 );
|
|
|
|
ck( static_cast<int*>(cp2.get()), 54321 );
|
|
|
|
ck( static_cast<int*>(ip), *cp2 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<int> cp3 ( cp );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( cp.use_count() == 3 );
|
|
|
|
BOOST_TEST( cp2.use_count() == 3 );
|
|
|
|
BOOST_TEST( cp3.use_count() == 3 );
|
|
|
|
cp.reset();
|
|
|
|
BOOST_TEST( cp2.use_count() == 2 );
|
|
|
|
BOOST_TEST( cp3.use_count() == 2 );
|
|
|
|
cp.reset( new int );
|
|
|
|
*cp = 98765;
|
|
|
|
BOOST_TEST( *cp == 98765 );
|
|
|
|
*cp3 = 87654;
|
|
|
|
BOOST_TEST( *cp3 == 87654 );
|
|
|
|
BOOST_TEST( *cp2 == 87654 );
|
|
|
|
cp.swap( cp3 );
|
|
|
|
BOOST_TEST( *cp == 87654 );
|
|
|
|
BOOST_TEST( *cp2 == 87654 );
|
|
|
|
BOOST_TEST( *cp3 == 98765 );
|
|
|
|
cp.swap( cp3 );
|
|
|
|
BOOST_TEST( *cp == 98765 );
|
|
|
|
BOOST_TEST( *cp2 == 87654 );
|
|
|
|
BOOST_TEST( *cp3 == 87654 );
|
|
|
|
cp2 = cp2;
|
|
|
|
BOOST_TEST( cp2.use_count() == 2 );
|
|
|
|
BOOST_TEST( *cp2 == 87654 );
|
|
|
|
cp = cp2;
|
|
|
|
BOOST_TEST( cp2.use_count() == 3 );
|
|
|
|
BOOST_TEST( *cp2 == 87654 );
|
|
|
|
BOOST_TEST( cp.use_count() == 3 );
|
|
|
|
BOOST_TEST( *cp == 87654 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<int> cp4;
|
2002-08-16 16:41:16 +00:00
|
|
|
swap( cp2, cp4 );
|
|
|
|
BOOST_TEST( cp4.use_count() == 3 );
|
|
|
|
BOOST_TEST( *cp4 == 87654 );
|
|
|
|
BOOST_TEST( cp2.get() == 0 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
std::set< boost::shared_ptr<int> > scp;
|
2002-08-16 16:41:16 +00:00
|
|
|
scp.insert(cp4);
|
|
|
|
BOOST_TEST( scp.find(cp4) != scp.end() );
|
2007-11-25 18:38:02 +00:00
|
|
|
BOOST_TEST( scp.find(cp4) == scp.find( boost::shared_ptr<int>(cp4) ) );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
// test shared_array with a built-in type
|
|
|
|
char * cap = new char [ 100 ];
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_array<char> ca ( cap );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( ca.get() == cap );
|
|
|
|
BOOST_TEST( cap == ca.get() );
|
|
|
|
BOOST_TEST( &ca[0] == cap );
|
|
|
|
|
|
|
|
strcpy( ca.get(), "Hot Dog with mustard and relish" );
|
|
|
|
BOOST_TEST( strcmp( ca.get(), "Hot Dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( strcmp( cap, "Hot Dog with mustard and relish" ) == 0 );
|
|
|
|
|
|
|
|
BOOST_TEST( ca[0] == 'H' );
|
|
|
|
BOOST_TEST( ca[30] == 'h' );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_array<char> ca2 ( ca );
|
|
|
|
boost::shared_array<char> ca3 ( ca2 );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
ca[0] = 'N';
|
|
|
|
ca[4] = 'd';
|
|
|
|
BOOST_TEST( strcmp( ca.get(), "Not dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( strcmp( ca2.get(), "Not dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( strcmp( ca3.get(), "Not dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( ca.use_count() == 3 );
|
|
|
|
BOOST_TEST( ca2.use_count() == 3 );
|
|
|
|
BOOST_TEST( ca3.use_count() == 3 );
|
|
|
|
ca2.reset();
|
|
|
|
BOOST_TEST( ca.use_count() == 2 );
|
|
|
|
BOOST_TEST( ca3.use_count() == 2 );
|
Merged revision(s) 81149, 81159, 81171, 81174, 81219-81220, 81222-81224, 81226, 81229-81239, 81242, 81253, 81257-81262, 81265-81268, 81271-81272, 81275-81277, 81299-81300 from trunk:
Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
........
Fix shared_ptr<T[]> EDG issues.
........
Disable make_shared<T> overloads when T is Q[].
........
Add catch(...) clauses to sp_array_test.cpp.
........
Add allocate_shared and make_shared for shared_ptr arrays of runtime size. Fulfills need for allocate_shared_array and make_shared_array.
........
Update Jamfile.v2 to run make_shared array tests and allocate_shared array tests.
........
Fix g++ issues.
........
Add specialization of sp_if_not_array<T[N]>.
........
Rename make_shared.hpp to make_shared_object.hpp, include from make_shared.hpp.
........
Add make_shared_array_args_test.cpp.
........
Add support for make_shared of array of arrays. Correctly destroy elements and construct elements for the variadic template constructor variants.
........
Fix sp_convertible<T const[], T const[]>.
........
Update smart_ptr/detail/array_helper to have create and create_noinit for non-array case.
........
Rename sp_convertible_test.cpp to shared_ptr_convertible_test.cpp.
........
Don't treat array_helper create and create_noinit for array types as a special case.
........
Add sp_convertible_test.cpp.
........
Fix array_helper (create_noinit and use of args...).
........
Update allocate_shared and make_shared to treat multidimensional array as single dimension. Remove detail array_helper. Add detail array traits. Update tests.
........
Simplify array_deleter interface
........
Add missing semicolon.
........
Fix typo.
........
Add tests for variadic template constructors overload of array forms of make_shared and allocate_shared for multidimensional arrays and up to 9 constructor arguments.
........
Add support for shared_ptr<X[N>.
........
Add C++11 initializer list support for make_shared and allocate_shared array forms.
........
Clean up code in allocate_shared_array.hpp and make_shared_array.hpp
........
Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
........
Disable make_shared for arrays when the compiler doesn't support partial specialization or SFINAE.
........
For allocate_shared and make_shared: Separate test case that g++ does support yet. Remove macros testing for no partial specialization in traits. Add additional traits.
........
Actually remove test cases from make_shared_array_create_test.cpp and allocate_shared_array_create_test.cpp that g++ does not handle.
........
Add overloads to support fixed size arrays, T[N], to allocate_shared (variadic) and make_shared (variadic) and make_shared_noinit.
........
Add additional overload for make_shared and allocate_shared for arrays for fixed size arrays and initializer lists.
........
Add assertion to overload of make_shared and allocate_shared for T[N] with initializer lists. Rename detail type to be more intuitive.
........
Add allocate_shared_array_args_test.cpp.
........
Keep old definition of sp_assert_convertible when BOOST_SP_NO_SP_CONVERTIBLE is set.
........
Updated shared_array to match shared_ptr. Refs #1113.
........
Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
........
Change traits for initializer list for g++
........
Tidy long line formatting in allocate_shared_array.hpp and make_shared_array.hpp
........
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
........
Update Jamfile.v2 with two new smart_ptr tests for allocate_shared and make_shared
........
[SVN r81339]
2012-11-14 13:52:11 +00:00
|
|
|
BOOST_TEST( ca2.use_count() == 0 );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
ca.reset();
|
|
|
|
BOOST_TEST( ca.get() == 0 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_array<char> ca4;
|
2002-08-16 16:41:16 +00:00
|
|
|
swap( ca3, ca4 );
|
|
|
|
BOOST_TEST( ca4.use_count() == 1 );
|
|
|
|
BOOST_TEST( strcmp( ca4.get(), "Not dog with mustard and relish" ) == 0 );
|
|
|
|
BOOST_TEST( ca3.get() == 0 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
std::set< boost::shared_array<char> > sca;
|
2002-08-16 16:41:16 +00:00
|
|
|
sca.insert(ca4);
|
|
|
|
BOOST_TEST( sca.find(ca4) != sca.end() );
|
2007-11-25 18:38:02 +00:00
|
|
|
BOOST_TEST( sca.find(ca4) == sca.find( boost::shared_array<char>(ca4) ) );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
// test shared_array with user defined type
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_array<UDT> udta ( new UDT[3] );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
udta[0].value( 111 );
|
|
|
|
udta[1].value( 222 );
|
|
|
|
udta[2].value( 333 );
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_array<UDT> udta2 ( udta );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
BOOST_TEST( udta[0].value() == 111 );
|
|
|
|
BOOST_TEST( udta[1].value() == 222 );
|
|
|
|
BOOST_TEST( udta[2].value() == 333 );
|
|
|
|
BOOST_TEST( udta2[0].value() == 111 );
|
|
|
|
BOOST_TEST( udta2[1].value() == 222 );
|
|
|
|
BOOST_TEST( udta2[2].value() == 333 );
|
|
|
|
udta2.reset();
|
|
|
|
BOOST_TEST( udta2.get() == 0 );
|
|
|
|
BOOST_TEST( udta.use_count() == 1 );
|
Merged revision(s) 81149, 81159, 81171, 81174, 81219-81220, 81222-81224, 81226, 81229-81239, 81242, 81253, 81257-81262, 81265-81268, 81271-81272, 81275-81277, 81299-81300 from trunk:
Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
........
Fix shared_ptr<T[]> EDG issues.
........
Disable make_shared<T> overloads when T is Q[].
........
Add catch(...) clauses to sp_array_test.cpp.
........
Add allocate_shared and make_shared for shared_ptr arrays of runtime size. Fulfills need for allocate_shared_array and make_shared_array.
........
Update Jamfile.v2 to run make_shared array tests and allocate_shared array tests.
........
Fix g++ issues.
........
Add specialization of sp_if_not_array<T[N]>.
........
Rename make_shared.hpp to make_shared_object.hpp, include from make_shared.hpp.
........
Add make_shared_array_args_test.cpp.
........
Add support for make_shared of array of arrays. Correctly destroy elements and construct elements for the variadic template constructor variants.
........
Fix sp_convertible<T const[], T const[]>.
........
Update smart_ptr/detail/array_helper to have create and create_noinit for non-array case.
........
Rename sp_convertible_test.cpp to shared_ptr_convertible_test.cpp.
........
Don't treat array_helper create and create_noinit for array types as a special case.
........
Add sp_convertible_test.cpp.
........
Fix array_helper (create_noinit and use of args...).
........
Update allocate_shared and make_shared to treat multidimensional array as single dimension. Remove detail array_helper. Add detail array traits. Update tests.
........
Simplify array_deleter interface
........
Add missing semicolon.
........
Fix typo.
........
Add tests for variadic template constructors overload of array forms of make_shared and allocate_shared for multidimensional arrays and up to 9 constructor arguments.
........
Add support for shared_ptr<X[N>.
........
Add C++11 initializer list support for make_shared and allocate_shared array forms.
........
Clean up code in allocate_shared_array.hpp and make_shared_array.hpp
........
Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
........
Disable make_shared for arrays when the compiler doesn't support partial specialization or SFINAE.
........
For allocate_shared and make_shared: Separate test case that g++ does support yet. Remove macros testing for no partial specialization in traits. Add additional traits.
........
Actually remove test cases from make_shared_array_create_test.cpp and allocate_shared_array_create_test.cpp that g++ does not handle.
........
Add overloads to support fixed size arrays, T[N], to allocate_shared (variadic) and make_shared (variadic) and make_shared_noinit.
........
Add additional overload for make_shared and allocate_shared for arrays for fixed size arrays and initializer lists.
........
Add assertion to overload of make_shared and allocate_shared for T[N] with initializer lists. Rename detail type to be more intuitive.
........
Add allocate_shared_array_args_test.cpp.
........
Keep old definition of sp_assert_convertible when BOOST_SP_NO_SP_CONVERTIBLE is set.
........
Updated shared_array to match shared_ptr. Refs #1113.
........
Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
........
Change traits for initializer list for g++
........
Tidy long line formatting in allocate_shared_array.hpp and make_shared_array.hpp
........
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
........
Update Jamfile.v2 with two new smart_ptr tests for allocate_shared and make_shared
........
[SVN r81339]
2012-11-14 13:52:11 +00:00
|
|
|
BOOST_TEST( udta2.use_count() == 0 );
|
2002-08-16 16:41:16 +00:00
|
|
|
|
|
|
|
BOOST_TEST( UDT_use_count == 4 ); // reality check
|
|
|
|
|
|
|
|
// test shared_ptr with a user defined type
|
|
|
|
UDT * up = new UDT;
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<UDT> sup ( up );
|
2002-08-16 16:41:16 +00:00
|
|
|
BOOST_TEST( up == sup.get() );
|
|
|
|
BOOST_TEST( sup.use_count() == 1 );
|
|
|
|
|
|
|
|
sup->value( 54321 ) ;
|
|
|
|
BOOST_TEST( sup->value() == 54321 );
|
|
|
|
BOOST_TEST( up->value() == 54321 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
boost::shared_ptr<UDT> sup2;
|
2002-08-16 16:41:16 +00:00
|
|
|
sup2 = sup;
|
|
|
|
BOOST_TEST( sup2->value() == 54321 );
|
|
|
|
BOOST_TEST( sup.use_count() == 2 );
|
|
|
|
BOOST_TEST( sup2.use_count() == 2 );
|
|
|
|
sup2 = sup2;
|
|
|
|
BOOST_TEST( sup2->value() == 54321 );
|
|
|
|
BOOST_TEST( sup.use_count() == 2 );
|
|
|
|
BOOST_TEST( sup2.use_count() == 2 );
|
|
|
|
|
2007-11-25 18:38:02 +00:00
|
|
|
std::cout << "OK\n";
|
2002-08-16 16:41:16 +00:00
|
|
|
}
|
2000-07-07 16:04:40 +00:00
|
|
|
|
2002-08-16 16:41:16 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test();
|
|
|
|
return boost::report_errors();
|
|
|
|
}
|