]>
git.saurik.com Git - wxWidgets.git/blob - tests/fontmap/fontmaptest.cpp
aa5a34d987476fb514b30608ebdef40e5c49b2df
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 wxT("Default encoding" ),
97 wxT("Western European (ISO-8859-1)" ),
98 wxT("Indian (ISO-8859-12)" ),
100 wxT("Unicode 7 bit (UTF-7)" ),
101 wxT("Windows Central European (CP 1250)"),
102 wxT("Windows Western European (CP 1252)"),
104 // and now some bogus ones
105 wxT("Default encoding" ),
106 wxT("Unknown encoding (-1)" ),
107 wxT("Unknown encoding (-1)" ),
108 wxT("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