+void wxAnyTestCase::Misc()
+{
+ // Do some (inplace) allocation sanity checks
+ {
+
+ // Do it inside a scope so we can easily test instance count
+ // afterwards
+ MyClass myObject(15);
+ wxAny any = myObject;
+
+ // There must be two instances - first in myObject,
+ // and second copied in any.
+ CPPUNIT_ASSERT_EQUAL(gs_myClassInstances.size(), 2);
+
+ // Check that it is allocated in-place, as supposed
+ if ( sizeof(MyClass) <= WX_ANY_VALUE_BUFFER_SIZE )
+ {
+ // Memory block of the instance second must be inside the any
+ size_t anyBegin = reinterpret_cast<size_t>(&any);
+ size_t anyEnd = anyBegin + sizeof(wxAny);
+ size_t pos = reinterpret_cast<size_t>(gs_myClassInstances[1]);
+ CPPUNIT_ASSERT( pos >= anyBegin );
+ CPPUNIT_ASSERT( pos < anyEnd );
+ }
+
+ wxAny any2 = any;
+ CPPUNIT_ASSERT( wxANY_AS(any2, MyClass).GetValue() == 15 );
+ }
+
+ // Make sure allocations and deallocations match
+ CPPUNIT_ASSERT_EQUAL(gs_myClassInstances.size(), 0);
+}
+