]> git.saurik.com Git - wxWidgets.git/blame - tests/fontmap/fontmaptest.cpp
Try native method first in LoadFile() and SaveFile()
[wxWidgets.git] / tests / fontmap / fontmaptest.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
816b59de 6// Copyright: (c) 2003 TT-Solutions
2229d9b3 7// Licence: wxWindows licence
816b59de
VS
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
8899b155 14#include "testprec.h"
816b59de
VS
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
816b59de
VS
28// ----------------------------------------------------------------------------
29// test class
30// ----------------------------------------------------------------------------
31
32class FontMapperTestCase : public CppUnit::TestCase
33{
34public:
35 FontMapperTestCase() { }
36
37private:
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
48CPPUNIT_TEST_SUITE_REGISTRATION( FontMapperTestCase );
49
e3778b4d 50// also include in its own registry so that these tests can be run alone
816b59de
VS
51CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontMapperTestCase, "FontMapperTestCase" );
52
53
54void FontMapperTestCase::NamesAndDesc()
55{
56 static const wxChar *charsets[] =
57 {
58 // some valid charsets
9a83f860
VZ
59 wxT("us-ascii" ),
60 wxT("iso8859-1" ),
61 wxT("iso-8859-12" ),
62 wxT("koi8-r" ),
63 wxT("utf-7" ),
64 wxT("cp1250" ),
65 wxT("windows-1252"),
816b59de
VS
66
67 // and now some bogus ones
9a83f860
VZ
68 wxT("" ),
69 wxT("cp1249" ),
70 wxT("iso--8859-1" ),
71 wxT("iso-8859-19" ),
816b59de
VS
72 };
73
74 static const wxChar *names[] =
75 {
76 // some valid charsets
9a83f860
VZ
77 wxT("default" ),
78 wxT("iso-8859-1" ),
79 wxT("iso-8859-12" ),
80 wxT("koi8-r" ),
81 wxT("utf-7" ),
82 wxT("windows-1250"),
83 wxT("windows-1252"),
816b59de
VS
84
85 // and now some bogus ones
9a83f860
VZ
86 wxT("default" ),
87 wxT("unknown--1" ),
88 wxT("unknown--1" ),
89 wxT("unknown--1" ),
816b59de
VS
90 };
91
92 static const wxChar *descriptions[] =
93 {
8b9e1f43 94 // some valid charsets
9a83f860
VZ
95 wxT("Default encoding" ),
96 wxT("Western European (ISO-8859-1)" ),
97 wxT("Indian (ISO-8859-12)" ),
98 wxT("KOI8-R" ),
99 wxT("Unicode 7 bit (UTF-7)" ),
100 wxT("Windows Central European (CP 1250)"),
101 wxT("Windows Western European (CP 1252)"),
816b59de
VS
102
103 // and now some bogus ones
9a83f860
VZ
104 wxT("Default encoding" ),
105 wxT("Unknown encoding (-1)" ),
106 wxT("Unknown encoding (-1)" ),
107 wxT("Unknown encoding (-1)" ),
816b59de
VS
108 };
109
788257c0 110 wxFontMapperBase& fmap = *wxFontMapperBase::Get();
816b59de
VS
111 for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
112 {
788257c0 113 wxFontEncoding enc = fmap.CharsetToEncoding(charsets[n]);
1de532f5
VZ
114 CPPUNIT_ASSERT_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
115 CPPUNIT_ASSERT_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
816b59de
VS
116 }
117}
118
119#endif // wxUSE_FONTMAP