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