]> git.saurik.com Git - wxWidgets.git/blob - tests/fontmap/fontmaptest.cpp
Fix compilation errors under OSX.
[wxWidgets.git] / tests / fontmap / fontmaptest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/fontmap/fontmap.cpp
3 // Purpose: wxFontMapper unit test
4 // Author: Vadim Zeitlin
5 // Created: 14.02.04
6 // RCS-ID: $Id$
7 // Copyright: (c) 2003 TT-Solutions
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ----------------------------------------------------------------------------
12 // headers
13 // ----------------------------------------------------------------------------
14
15 #include "testprec.h"
16
17 #ifdef __BORLANDC__
18 #pragma hdrstop
19 #endif
20
21 #ifndef WX_PRECOMP
22 #include "wx/wx.h"
23 #endif // WX_PRECOMP
24
25 #if wxUSE_FONTMAP
26
27 #include "wx/fontmap.h"
28
29 // ----------------------------------------------------------------------------
30 // test class
31 // ----------------------------------------------------------------------------
32
33 class FontMapperTestCase : public CppUnit::TestCase
34 {
35 public:
36 FontMapperTestCase() { }
37
38 private:
39 CPPUNIT_TEST_SUITE( FontMapperTestCase );
40 CPPUNIT_TEST( NamesAndDesc );
41 CPPUNIT_TEST_SUITE_END();
42
43 void NamesAndDesc();
44
45 DECLARE_NO_COPY_CLASS(FontMapperTestCase)
46 };
47
48 // register in the unnamed registry so that these tests are run by default
49 CPPUNIT_TEST_SUITE_REGISTRATION( FontMapperTestCase );
50
51 // also include in its own registry so that these tests can be run alone
52 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontMapperTestCase, "FontMapperTestCase" );
53
54
55 void FontMapperTestCase::NamesAndDesc()
56 {
57 static const wxChar *charsets[] =
58 {
59 // some valid charsets
60 wxT("us-ascii" ),
61 wxT("iso8859-1" ),
62 wxT("iso-8859-12" ),
63 wxT("koi8-r" ),
64 wxT("utf-7" ),
65 wxT("cp1250" ),
66 wxT("windows-1252"),
67
68 // and now some bogus ones
69 wxT("" ),
70 wxT("cp1249" ),
71 wxT("iso--8859-1" ),
72 wxT("iso-8859-19" ),
73 };
74
75 static const wxChar *names[] =
76 {
77 // some valid charsets
78 wxT("default" ),
79 wxT("iso-8859-1" ),
80 wxT("iso-8859-12" ),
81 wxT("koi8-r" ),
82 wxT("utf-7" ),
83 wxT("windows-1250"),
84 wxT("windows-1252"),
85
86 // and now some bogus ones
87 wxT("default" ),
88 wxT("unknown--1" ),
89 wxT("unknown--1" ),
90 wxT("unknown--1" ),
91 };
92
93 static const wxChar *descriptions[] =
94 {
95 // some valid charsets
96 wxT("Default encoding" ),
97 wxT("Western European (ISO-8859-1)" ),
98 wxT("Indian (ISO-8859-12)" ),
99 wxT("KOI8-R" ),
100 wxT("Unicode 7 bit (UTF-7)" ),
101 wxT("Windows Central European (CP 1250)"),
102 wxT("Windows Western European (CP 1252)"),
103
104 // and now some bogus ones
105 wxT("Default encoding" ),
106 wxT("Unknown encoding (-1)" ),
107 wxT("Unknown encoding (-1)" ),
108 wxT("Unknown encoding (-1)" ),
109 };
110
111 wxFontMapperBase& fmap = *wxFontMapperBase::Get();
112 for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
113 {
114 wxFontEncoding enc = fmap.CharsetToEncoding(charsets[n]);
115 CPPUNIT_ASSERT_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
116 CPPUNIT_ASSERT_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
117 }
118 }
119
120 #endif // wxUSE_FONTMAP