]> git.saurik.com Git - wxWidgets.git/blame - tests/fontmap/fontmaptest.cpp
unbuffer cout to work around bug in Debian version of cppunit
[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
51// also include in it's own registry so that these tests can be run alone
52CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontMapperTestCase, "FontMapperTestCase" );
53
54
55void FontMapperTestCase::NamesAndDesc()
56{
57 static const wxChar *charsets[] =
58 {
59 // some valid charsets
60 _T("us-ascii" ),
61 _T("iso8859-1" ),
62 _T("iso-8859-12" ),
63 _T("koi8-r" ),
64 _T("utf-7" ),
65 _T("cp1250" ),
66 _T("windows-1252"),
67
68 // and now some bogus ones
69 _T("" ),
70 _T("cp1249" ),
71 _T("iso--8859-1" ),
72 _T("iso-8859-19" ),
73 };
74
75 static const wxChar *names[] =
76 {
77 // some valid charsets
78 _T("default" ),
79 _T("iso-8859-1" ),
80 _T("iso-8859-12" ),
81 _T("koi8-r" ),
82 _T("utf-7" ),
83 _T("windows-1250"),
84 _T("windows-1252"),
85
86 // and now some bogus ones
87 _T("default" ),
88 _T("unknown--1" ),
89 _T("unknown--1" ),
90 _T("unknown--1" ),
91 };
92
93 static const wxChar *descriptions[] =
94 {
8b9e1f43 95 // some valid charsets
816b59de
VS
96 _T("Default encoding" ),
97 _T("Western European (ISO-8859-1)" ),
98 _T("Indian (ISO-8859-12)" ),
99 _T("KOI8-R" ),
100 _T("Unicode 7 bit (UTF-7)" ),
101 _T("Windows Central European (CP 1250)"),
102 _T("Windows Western European (CP 1252)"),
103
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)" ),
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