Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58123 - trunk/libs/smart_ptr/test
From: pdimov_at_[hidden]
Date: 2009-12-03 13:10:38


Author: pdimov
Date: 2009-12-03 13:10:37 EST (Thu, 03 Dec 2009)
New Revision: 58123
URL: http://svn.boost.org/trac/boost/changeset/58123

Log:
Fix smart_ptr tests to not require RTTI.
Text files modified:
   trunk/libs/smart_ptr/test/pointer_cast_test.cpp | 10 ++++++++++
   trunk/libs/smart_ptr/test/shared_from_this_test.cpp | 2 ++
   trunk/libs/smart_ptr/test/shared_ptr_basic_test.cpp | 12 ++++++++++++
   trunk/libs/smart_ptr/test/shared_ptr_test.cpp | 8 ++++++++
   4 files changed, 32 insertions(+), 0 deletions(-)

Modified: trunk/libs/smart_ptr/test/pointer_cast_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/pointer_cast_test.cpp (original)
+++ trunk/libs/smart_ptr/test/pointer_cast_test.cpp 2009-12-03 13:10:37 EST (Thu, 03 Dec 2009)
@@ -9,6 +9,8 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 
+#include <boost/config.hpp>
+
 #include <boost/pointer_cast.hpp>
 
 #include <boost/shared_ptr.hpp>
@@ -58,6 +60,8 @@
 
 // And now some simple check functions
 
+#if !defined( BOOST_NO_RTTI )
+
 template <class BasePtr>
 bool check_dynamic_pointer_cast(const BasePtr &ptr)
 {
@@ -74,6 +78,8 @@
       dynamic_cast<derived_derived*>(boost::get_pointer(ptr));
 }
 
+#endif
+
 template <class BasePtr>
 bool check_static_pointer_cast(const BasePtr &ptr)
 {
@@ -107,7 +113,9 @@
 
         boost::shared_ptr<base> ptr(new derived);
 
+#if !defined( BOOST_NO_RTTI )
         BOOST_TEST( check_dynamic_pointer_cast( ptr ) );
+#endif
         BOOST_TEST( check_static_pointer_cast( ptr ) );
         BOOST_TEST( check_const_pointer_cast( ptr ) );
     }
@@ -117,7 +125,9 @@
 
         boost::scoped_ptr<base> ptr(new derived);
 
+#if !defined( BOOST_NO_RTTI )
         BOOST_TEST( check_dynamic_pointer_cast( ptr.get() ) );
+#endif
         BOOST_TEST( check_static_pointer_cast( ptr.get() ) );
         BOOST_TEST( check_const_pointer_cast( ptr.get() ) );
     }

Modified: trunk/libs/smart_ptr/test/shared_from_this_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/shared_from_this_test.cpp (original)
+++ trunk/libs/smart_ptr/test/shared_from_this_test.cpp 2009-12-03 13:10:37 EST (Thu, 03 Dec 2009)
@@ -63,10 +63,12 @@
 
         px->f();
 
+#if !defined( BOOST_NO_RTTI )
         boost::shared_ptr<Y> py2 = boost::dynamic_pointer_cast<Y>(px);
         BOOST_TEST(py.get() == py2.get());
         BOOST_TEST(!(py < py2 || py2 < py));
         BOOST_TEST(py.use_count() == 3);
+#endif
     }
     catch( boost::bad_weak_ptr const& )
     {

Modified: trunk/libs/smart_ptr/test/shared_ptr_basic_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/shared_ptr_basic_test.cpp (original)
+++ trunk/libs/smart_ptr/test/shared_ptr_basic_test.cpp 2009-12-03 13:10:37 EST (Thu, 03 Dec 2009)
@@ -188,6 +188,7 @@
             test_eq(p, q);
         }
 
+#if !defined( BOOST_NO_RTTI )
         shared_ptr<Y> p3 = dynamic_pointer_cast<Y>(p);
         shared_ptr<Y> p4 = dynamic_pointer_cast<Y>(p2);
 
@@ -201,6 +202,7 @@
         test_is_Y(p3);
         test_eq2(p, p3);
         test_ne2(p2, p4);
+#endif
 
         shared_ptr<void> p5(p);
 
@@ -214,13 +216,17 @@
 
         p.reset();
         p2.reset();
+#if !defined( BOOST_NO_RTTI )
         p3.reset();
         p4.reset();
+#endif
 
         test_is_zero(p);
         test_is_zero(p2);
+#if !defined( BOOST_NO_RTTI )
         test_is_zero(p3);
         test_is_zero(p4);
+#endif
 
         BOOST_TEST(p5.use_count() == 1);
 
@@ -250,6 +256,7 @@
             test_is_nonzero(wp2.lock());
         }
 
+#if !defined( BOOST_NO_RTTI )
         weak_ptr<Y> wp3 = dynamic_pointer_cast<Y>(wp2.lock());
 
         BOOST_TEST(wp3.use_count() == 1);
@@ -259,12 +266,15 @@
 
         BOOST_TEST(wp4.use_count() == 1);
         test_shared(wp2, wp4);
+#endif
 
         wp1 = p2;
         test_is_zero(wp1.lock());
 
+#if !defined( BOOST_NO_RTTI )
         wp1 = p4;
         wp1 = wp3;
+#endif
         wp1 = wp2;
 
         BOOST_TEST(wp1.use_count() == 1);
@@ -279,7 +289,9 @@
 
         BOOST_TEST(wp1.use_count() == 0);
         BOOST_TEST(wp2.use_count() == 0);
+#if !defined( BOOST_NO_RTTI )
         BOOST_TEST(wp3.use_count() == 0);
+#endif
 
         // Test operator< stability for std::set< weak_ptr<> >
         // Thanks to Joe Gottman for pointing this out

Modified: trunk/libs/smart_ptr/test/shared_ptr_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/shared_ptr_test.cpp (original)
+++ trunk/libs/smart_ptr/test/shared_ptr_test.cpp 2009-12-03 13:10:37 EST (Thu, 03 Dec 2009)
@@ -2462,6 +2462,8 @@
 
 } // namespace n_const_cast
 
+#if !defined( BOOST_NO_RTTI )
+
 namespace n_dynamic_cast
 {
 
@@ -2527,6 +2529,8 @@
 
 } // namespace n_dynamic_cast
 
+#endif
+
 namespace n_map
 {
 
@@ -3200,10 +3204,12 @@
     BOOST_TEST(px.get() != 0);
     BOOST_TEST(py.use_count() == 2);
 
+#if !defined( BOOST_NO_RTTI )
     boost::shared_ptr<Y> py2 = boost::dynamic_pointer_cast<Y>(px);
     BOOST_TEST(py.get() == py2.get());
     BOOST_TEST(!(py < py2 || py2 < py));
     BOOST_TEST(py.use_count() == 3);
+#endif
 }
 
 } // namespace n_spt_shared_from_this
@@ -3229,7 +3235,9 @@
     n_comparison::test();
     n_static_cast::test();
     n_const_cast::test();
+#if !defined( BOOST_NO_RTTI )
     n_dynamic_cast::test();
+#endif
 
     n_map::test();
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk