]>
git.saurik.com Git - wxWidgets.git/blob - tests/misc/typeinfotest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/typeinfotest.cpp
3 // Purpose: Test typeinfo.h
4 // Author: Jaakko Salli
6 // Copyright: (c) the wxWidgets team
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
16 #include "wx/typeinfo.h"
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 class TypeInfoTestCase
: public CppUnit::TestCase
25 TypeInfoTestCase() { }
28 CPPUNIT_TEST_SUITE( TypeInfoTestCase
);
30 CPPUNIT_TEST_SUITE_END();
34 DECLARE_NO_COPY_CLASS(TypeInfoTestCase
)
37 // register in the unnamed registry so that these tests are run by default
38 CPPUNIT_TEST_SUITE_REGISTRATION( TypeInfoTestCase
);
40 // also include in it's own registry so that these tests can be run alone
41 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TypeInfoTestCase
, "TypeInfoTestCase" );
44 namespace UserNameSpace
{
47 WX_DECLARE_TYPEINFO_INLINE(UserType1
)
49 virtual ~UserType1() { }
55 WX_DECLARE_TYPEINFO_INLINE(UserType1
)
57 virtual ~UserType1() { }
62 WX_DECLARE_TYPEINFO(UserType2
)
64 virtual ~UserType2() { }
67 WX_DEFINE_TYPEINFO(UserType2
)
69 void TypeInfoTestCase::Test()
71 UserNameSpace::UserType1 uns_ut1
;
72 UserNameSpace::UserType1
* uns_ut1_p
= new UserNameSpace::UserType1();
74 UserType1
* ut1_p
= new UserType1();
76 UserType2
* ut2_p
= new UserType2();
78 // These type comparison should match
79 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) == wxTypeId(*uns_ut1_p
));
80 CPPUNIT_ASSERT(wxTypeId(ut1
) == wxTypeId(*ut1_p
));
81 CPPUNIT_ASSERT(wxTypeId(ut2
) == wxTypeId(*ut2_p
));
83 // These type comparison should not match
84 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) != wxTypeId(ut1
));
85 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) != wxTypeId(ut2
));
86 CPPUNIT_ASSERT(wxTypeId(ut1
) != wxTypeId(ut2
));