Home | History | Annotate | Download | only in unit
      1 #include <memory>
      2 
      3 #if !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT)
      4 
      5 // #include <typeinfo>
      6 #include "cppunit/cppunit_proxy.h"
      7 
      8 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
      9 using namespace std;
     10 #endif
     11 
     12 class SharedPtrTest :
     13     public CPPUNIT_NS::TestCase
     14 {
     15     CPPUNIT_TEST_SUITE(SharedPtrTest);
     16     CPPUNIT_TEST(shared_from_this);
     17     CPPUNIT_TEST_SUITE_END();
     18 
     19   protected:
     20     void shared_from_this();
     21 };
     22 
     23 CPPUNIT_TEST_SUITE_REGISTRATION(SharedPtrTest);
     24 
     25 struct X;
     26 
     27 struct X :
     28     public std::tr1::enable_shared_from_this<X>
     29 {
     30 };
     31 
     32 void SharedPtrTest::shared_from_this()
     33 {
     34   std::tr1::shared_ptr<X> p( new X );
     35   std::tr1::shared_ptr<X> q = p->shared_from_this();
     36 
     37   CPPUNIT_CHECK( p == q );
     38   CPPUNIT_CHECK( !(p < q) && !(q < p) ); // p and q share ownership
     39 }
     40 
     41 #endif /* !_STLP_NO_EXTENSIONS && _STLP_USE_BOOST_SUPPORT */
     42