]>
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
5 // Copyright: (c) the wxWidgets team
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
15 #include "wx/typeinfo.h"
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 class TypeInfoTestCase
: public CppUnit::TestCase
24 TypeInfoTestCase() { }
27 CPPUNIT_TEST_SUITE( TypeInfoTestCase
);
29 CPPUNIT_TEST_SUITE_END();
33 DECLARE_NO_COPY_CLASS(TypeInfoTestCase
)
36 // register in the unnamed registry so that these tests are run by default
37 CPPUNIT_TEST_SUITE_REGISTRATION( TypeInfoTestCase
);
39 // also include in its own registry so that these tests can be run alone
40 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TypeInfoTestCase
, "TypeInfoTestCase" );
43 namespace UserNameSpace
{
46 WX_DECLARE_TYPEINFO_INLINE(UserType1
)
48 virtual ~UserType1() { }
54 WX_DECLARE_TYPEINFO_INLINE(UserType1
)
56 virtual ~UserType1() { }
61 WX_DECLARE_TYPEINFO(UserType2
)
63 virtual ~UserType2() { }
66 WX_DEFINE_TYPEINFO(UserType2
)
68 void TypeInfoTestCase::Test()
70 UserNameSpace::UserType1 uns_ut1
;
71 UserNameSpace::UserType1
* uns_ut1_p
= new UserNameSpace::UserType1();
73 UserType1
* ut1_p
= new UserType1();
75 UserType2
* ut2_p
= new UserType2();
77 // These type comparison should match
78 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) == wxTypeId(*uns_ut1_p
));
79 CPPUNIT_ASSERT(wxTypeId(ut1
) == wxTypeId(*ut1_p
));
80 CPPUNIT_ASSERT(wxTypeId(ut2
) == wxTypeId(*ut2_p
));
82 // These type comparison should not match
83 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) != wxTypeId(ut1
));
84 CPPUNIT_ASSERT(wxTypeId(uns_ut1
) != wxTypeId(ut2
));
85 CPPUNIT_ASSERT(wxTypeId(ut1
) != wxTypeId(ut2
));