]> git.saurik.com Git - wxWidgets.git/blob - tests/misc/typeinfotest.cpp
Remove "release" suffix from wx-config links used in RPMs.
[wxWidgets.git] / tests / misc / typeinfotest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/typeinfotest.cpp
3 // Purpose: Test typeinfo.h
4 // Author: Jaakko Salli
5 // RCS-ID: $Id$
6 // Copyright: (c) the wxWidgets team
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "testprec.h"
11
12 #ifdef __BORLANDC__
13 # pragma hdrstop
14 #endif
15
16 #include "wx/typeinfo.h"
17
18 // ----------------------------------------------------------------------------
19 // test class
20 // ----------------------------------------------------------------------------
21
22 class TypeInfoTestCase : public CppUnit::TestCase
23 {
24 public:
25 TypeInfoTestCase() { }
26
27 private:
28 CPPUNIT_TEST_SUITE( TypeInfoTestCase );
29 CPPUNIT_TEST( Test );
30 CPPUNIT_TEST_SUITE_END();
31
32 void Test();
33
34 DECLARE_NO_COPY_CLASS(TypeInfoTestCase)
35 };
36
37 // register in the unnamed registry so that these tests are run by default
38 CPPUNIT_TEST_SUITE_REGISTRATION( TypeInfoTestCase );
39
40 // also include in it's own registry so that these tests can be run alone
41 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TypeInfoTestCase, "TypeInfoTestCase" );
42
43
44 namespace UserNameSpace {
45 class UserType1
46 {
47 WX_DECLARE_TYPEINFO_INLINE(UserType1)
48 public:
49 virtual ~UserType1() { }
50 };
51 }
52
53 class UserType1
54 {
55 WX_DECLARE_TYPEINFO_INLINE(UserType1)
56 public:
57 virtual ~UserType1() { }
58 };
59
60 class UserType2
61 {
62 WX_DECLARE_TYPEINFO(UserType2)
63 public:
64 virtual ~UserType2() { }
65 };
66
67 WX_DEFINE_TYPEINFO(UserType2)
68
69 void TypeInfoTestCase::Test()
70 {
71 UserNameSpace::UserType1 uns_ut1;
72 UserNameSpace::UserType1* uns_ut1_p = new UserNameSpace::UserType1();
73 UserType1 ut1;
74 UserType1* ut1_p = new UserType1();
75 UserType2 ut2;
76 UserType2* ut2_p = new UserType2();
77
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));
82
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));
87
88 delete uns_ut1_p;
89 delete ut1_p;
90 delete ut2_p;
91 }
92