]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/weakref/weakref.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / tests / weakref / weakref.cpp
index ef1b8ad0f8985172b33c9639a27bad0c345504b6..4922daac5eaeade5fb6c889c6c7b0ebc5f481cba 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxWeakRef<T> unit test
 // Author:      Arne Steinarson
 // Created:     2008-01-10
-// RCS-ID:      $Id$
 // Copyright:   (c) 2007 Arne Steinarson
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -73,9 +72,17 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( WeakRefTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WeakRefTestCase, "WeakRefTestCase" );
 
+
+// Test weak reference to an incomplete type, this should work if the type is
+// fully defined before it is used (but currently doesn't, see #11916)
+struct ForwardDeclaredClass;
+wxWeakRef<ForwardDeclaredClass> g_incompleteWeakRef;
+
+struct ForwardDeclaredClass : wxEvtHandler { };
+
 void WeakRefTestCase::DeclareTest()
 {
     {
@@ -110,6 +117,17 @@ void WeakRefTestCase::DeclareTest()
         CPPUNIT_ASSERT( wreh.get() == &eh );
         CPPUNIT_ASSERT( wrot.get() == &ot );
     }
+
+    // This test requires a working dynamic_cast<>
+#ifndef wxNO_RTTI
+    {
+        ForwardDeclaredClass fdc;
+        g_incompleteWeakRef = &fdc;
+        CPPUNIT_ASSERT( g_incompleteWeakRef );
+    }
+
+    CPPUNIT_ASSERT( !g_incompleteWeakRef );
+#endif // RTTI enabled
 }
 
 void WeakRefTestCase::AssignTest()