]> git.saurik.com Git - wxWidgets.git/blame_incremental - tests/misc/typeinfotest.cpp
Basque translations update from Xabier Aramendi.
[wxWidgets.git] / tests / misc / typeinfotest.cpp
... / ...
CommitLineData
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///////////////////////////////////////////////////////////////////////////////
8
9#include "testprec.h"
10
11#ifdef __BORLANDC__
12# pragma hdrstop
13#endif
14
15#include "wx/typeinfo.h"
16
17// ----------------------------------------------------------------------------
18// test class
19// ----------------------------------------------------------------------------
20
21class TypeInfoTestCase : public CppUnit::TestCase
22{
23public:
24 TypeInfoTestCase() { }
25
26private:
27 CPPUNIT_TEST_SUITE( TypeInfoTestCase );
28 CPPUNIT_TEST( Test );
29 CPPUNIT_TEST_SUITE_END();
30
31 void Test();
32
33 DECLARE_NO_COPY_CLASS(TypeInfoTestCase)
34};
35
36// register in the unnamed registry so that these tests are run by default
37CPPUNIT_TEST_SUITE_REGISTRATION( TypeInfoTestCase );
38
39// also include in its own registry so that these tests can be run alone
40CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TypeInfoTestCase, "TypeInfoTestCase" );
41
42
43namespace UserNameSpace {
44 class UserType1
45 {
46 WX_DECLARE_TYPEINFO_INLINE(UserType1)
47 public:
48 virtual ~UserType1() { }
49 };
50}
51
52class UserType1
53{
54 WX_DECLARE_TYPEINFO_INLINE(UserType1)
55public:
56 virtual ~UserType1() { }
57};
58
59class UserType2
60{
61 WX_DECLARE_TYPEINFO(UserType2)
62public:
63 virtual ~UserType2() { }
64};
65
66WX_DEFINE_TYPEINFO(UserType2)
67
68void TypeInfoTestCase::Test()
69{
70 UserNameSpace::UserType1 uns_ut1;
71 UserNameSpace::UserType1* uns_ut1_p = new UserNameSpace::UserType1();
72 UserType1 ut1;
73 UserType1* ut1_p = new UserType1();
74 UserType2 ut2;
75 UserType2* ut2_p = new UserType2();
76
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));
81
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));
86
87 delete uns_ut1_p;
88 delete ut1_p;
89 delete ut2_p;
90}
91