]> git.saurik.com Git - wxWidgets.git/blame - tests/mbconv/mbconvtest.cpp
Move wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW out of the common section in
[wxWidgets.git] / tests / mbconv / mbconvtest.cpp
CommitLineData
2cc07181
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/mbconv/main.cpp
3// Purpose: wxMBConv unit test
4// Author: Vadim Zeitlin
5// Created: 14.02.04
6// RCS-ID: $Id$
7// Copyright: (c) 2003 TT-Solutions
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
8899b155 14#include "testprec.h"
20f46e8d
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
2cc07181
VZ
24#include "wx/strconv.h"
25#include "wx/string.h"
26
2cc07181
VZ
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
31class MBConvTestCase : public CppUnit::TestCase
32{
33public:
34 MBConvTestCase() { }
35
36private:
37 CPPUNIT_TEST_SUITE( MBConvTestCase );
38 CPPUNIT_TEST( WC2CP1250 );
39 CPPUNIT_TEST_SUITE_END();
40
41 void WC2CP1250();
42
20f46e8d 43 DECLARE_NO_COPY_CLASS(MBConvTestCase)
2cc07181
VZ
44};
45
98eae466
VS
46// register in the unnamed registry so that these tests are run by default
47CPPUNIT_TEST_SUITE_REGISTRATION( MBConvTestCase );
48
49// also include in it's own registry so that these tests can be run alone
2cc07181
VZ
50CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" );
51
52void MBConvTestCase::WC2CP1250()
53{
54 static const struct Data
55 {
56 const wchar_t *wc;
57 const char *cp1250;
58 } data[] =
59 {
60 { L"hello", "hello" }, // test that it works in simplest case
a430a60f 61 { L"\xBD of \xBD is \xBC", NULL }, // this should fail as cp1250 doesn't have 1/2
2cc07181
VZ
62 };
63
64 wxCSConv cs1250(wxFONTENCODING_CP1250);
65 for ( size_t n = 0; n < WXSIZEOF(data); n++ )
66 {
67 const Data& d = data[n];
98eae466
VS
68 if (d.cp1250)
69 {
70 CPPUNIT_ASSERT( strcmp(cs1250.cWC2MB(d.wc), d.cp1250) == 0 );
71 }
72 else
73 {
0f216992 74 CPPUNIT_ASSERT( (const char*)cs1250.cWC2MB(d.wc) == NULL );
98eae466 75 }
2cc07181
VZ
76 }
77}