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