]> git.saurik.com Git - wxWidgets.git/blame - tests/fontmap/fontmaptest.cpp
Make wxMSW wxSpinCtrl "not enough space" messages more helpful.
[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
6// RCS-ID: $Id$
7// Copyright: (c) 2003 TT-Solutions
2229d9b3 8// Licence: wxWindows licence
816b59de
VS
9///////////////////////////////////////////////////////////////////////////////
10
11// ----------------------------------------------------------------------------
12// headers
13// ----------------------------------------------------------------------------
14
8899b155 15#include "testprec.h"
816b59de
VS
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
816b59de
VS
29// ----------------------------------------------------------------------------
30// test class
31// ----------------------------------------------------------------------------
32
33class FontMapperTestCase : public CppUnit::TestCase
34{
35public:
36 FontMapperTestCase() { }
37
38private:
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
49CPPUNIT_TEST_SUITE_REGISTRATION( FontMapperTestCase );
50
e3778b4d 51// also include in its own registry so that these tests can be run alone
816b59de
VS
52CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontMapperTestCase, "FontMapperTestCase" );
53
54
55void FontMapperTestCase::NamesAndDesc()
56{
57 static const wxChar *charsets[] =
58 {
59 // some valid charsets
9a83f860
VZ
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"),
816b59de
VS
67
68 // and now some bogus ones
9a83f860
VZ
69 wxT("" ),
70 wxT("cp1249" ),
71 wxT("iso--8859-1" ),
72 wxT("iso-8859-19" ),
816b59de
VS
73 };
74
75 static const wxChar *names[] =
76 {
77 // some valid charsets
9a83f860
VZ
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"),
816b59de
VS
85
86 // and now some bogus ones
9a83f860
VZ
87 wxT("default" ),
88 wxT("unknown--1" ),
89 wxT("unknown--1" ),
90 wxT("unknown--1" ),
816b59de
VS
91 };
92
93 static const wxChar *descriptions[] =
94 {
8b9e1f43 95 // some valid charsets
9a83f860
VZ
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)"),
816b59de
VS
103
104 // and now some bogus ones
9a83f860
VZ
105 wxT("Default encoding" ),
106 wxT("Unknown encoding (-1)" ),
107 wxT("Unknown encoding (-1)" ),
108 wxT("Unknown encoding (-1)" ),
816b59de
VS
109 };
110
788257c0 111 wxFontMapperBase& fmap = *wxFontMapperBase::Get();
816b59de
VS
112 for ( size_t n = 0; n < WXSIZEOF(charsets); n++ )
113 {
788257c0 114 wxFontEncoding enc = fmap.CharsetToEncoding(charsets[n]);
1de532f5
VZ
115 CPPUNIT_ASSERT_EQUAL( names[n], fmap.GetEncodingName(enc).Lower() );
116 CPPUNIT_ASSERT_EQUAL( descriptions[n], fmap.GetEncodingDescription(enc) );
816b59de
VS
117 }
118}
119
120#endif // wxUSE_FONTMAP