]> git.saurik.com Git - wxWidgets.git/blob - tests/mbconv/main.cpp
compilation fix for unicode
[wxWidgets.git] / tests / mbconv / main.cpp
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
14 #include "wx/wx.h"
15 #include "wx/strconv.h"
16 #include "wx/string.h"
17
18 #include "wx/cppunit.h"
19
20 // ----------------------------------------------------------------------------
21 // test class
22 // ----------------------------------------------------------------------------
23
24 class MBConvTestCase : public CppUnit::TestCase
25 {
26 public:
27 MBConvTestCase() { }
28
29 private:
30 CPPUNIT_TEST_SUITE( MBConvTestCase );
31 CPPUNIT_TEST( WC2CP1250 );
32 CPPUNIT_TEST_SUITE_END();
33
34 void WC2CP1250();
35
36 DECLARE_NO_COPY_CLASS(MBConvTestCase);
37 };
38
39 // register in the unnamed registry so that these tests are run by default
40 CPPUNIT_TEST_SUITE_REGISTRATION( MBConvTestCase );
41
42 // also include in it's own registry so that these tests can be run alone
43 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" );
44
45 void MBConvTestCase::WC2CP1250()
46 {
47 static const struct Data
48 {
49 const wchar_t *wc;
50 const char *cp1250;
51 } data[] =
52 {
53 { L"hello", "hello" }, // test that it works in simplest case
54 { L"½ of ½ is ¼", NULL }, // this should fail as cp1250 doesn't have 1/2
55 };
56
57 wxCSConv cs1250(wxFONTENCODING_CP1250);
58 for ( size_t n = 0; n < WXSIZEOF(data); n++ )
59 {
60 const Data& d = data[n];
61 if (d.cp1250)
62 {
63 CPPUNIT_ASSERT( strcmp(cs1250.cWC2MB(d.wc), d.cp1250) == 0 );
64 }
65 else
66 {
67 CPPUNIT_ASSERT( cs1250.cWC2MB(d.wc) == NULL );
68 }
69 }
70 }