]>
git.saurik.com Git - wxWidgets.git/blob - tests/fontmap/fontmaptest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/fontmap/fontmap.cpp
3 // Purpose: wxFontMapper unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2003 TT-Solutions
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ----------------------------------------------------------------------------
13 // ----------------------------------------------------------------------------
27 #include "wx/fontmap.h"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 class FontMapperTestCase
: public CppUnit::TestCase
36 FontMapperTestCase() { }
39 CPPUNIT_TEST_SUITE( FontMapperTestCase
);
40 CPPUNIT_TEST( NamesAndDesc
);
41 CPPUNIT_TEST_SUITE_END();
45 DECLARE_NO_COPY_CLASS(FontMapperTestCase
)
48 // register in the unnamed registry so that these tests are run by default
49 CPPUNIT_TEST_SUITE_REGISTRATION( FontMapperTestCase
);
51 // also include in it's own registry so that these tests can be run alone
52 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontMapperTestCase
, "FontMapperTestCase" );
55 void FontMapperTestCase::NamesAndDesc()
57 static const wxChar
*charsets
[] =
59 // some valid charsets
68 // and now some bogus ones
75 static const wxChar
*names
[] =
77 // some valid charsets
86 // and now some bogus ones
93 static const wxChar
*descriptions
[] =
95 // some valid charsets
96 _T("Default encoding" ),
97 _T("Western European (ISO-8859-1)" ),
98 _T("Indian (ISO-8859-12)" ),
100 _T("Unicode 7 bit (UTF-7)" ),
101 _T("Windows Central European (CP 1250)"),
102 _T("Windows Western European (CP 1252)"),
104 // and now some bogus ones
105 _T("Default encoding" ),
106 _T("Unknown encoding (-1)" ),
107 _T("Unknown encoding (-1)" ),
108 _T("Unknown encoding (-1)" ),
111 wxFontMapperBase
& fmap
= *wxFontMapperBase::Get();
112 for ( size_t n
= 0; n
< WXSIZEOF(charsets
); n
++ )
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
) );
120 #endif // wxUSE_FONTMAP