]> git.saurik.com Git - wxWidgets.git/blame - tests/misc/typeinfotest.cpp
Added NSApplicationDelegate's openFiles for wxOSX-Cocoa.
[wxWidgets.git] / tests / misc / typeinfotest.cpp
CommitLineData
7db064f6
JS
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
22class TypeInfoTestCase : public CppUnit::TestCase
23{
24public:
25 TypeInfoTestCase() { }
26
27private:
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
38CPPUNIT_TEST_SUITE_REGISTRATION( TypeInfoTestCase );
39
e3778b4d 40// also include in its own registry so that these tests can be run alone
7db064f6
JS
41CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TypeInfoTestCase, "TypeInfoTestCase" );
42
43
44namespace UserNameSpace {
45 class UserType1
46 {
47 WX_DECLARE_TYPEINFO_INLINE(UserType1)
48 public:
49 virtual ~UserType1() { }
50 };
51}
52
53class UserType1
54{
55 WX_DECLARE_TYPEINFO_INLINE(UserType1)
56public:
57 virtual ~UserType1() { }
58};
59
60class UserType2
61{
62 WX_DECLARE_TYPEINFO(UserType2)
63public:
64 virtual ~UserType2() { }
65};
66
67WX_DEFINE_TYPEINFO(UserType2)
68
69void 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