]> git.saurik.com Git - wxWidgets.git/blob - tests/mbconv/main.cpp
Added docstrings
[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/strconv.h"
15 #include "wx/string.h"
16
17 #include "wx/cppunit.h"
18
19 // ----------------------------------------------------------------------------
20 // test class
21 // ----------------------------------------------------------------------------
22
23 class MBConvTestCase : public CppUnit::TestCase
24 {
25 public:
26 MBConvTestCase() { }
27
28 private:
29 CPPUNIT_TEST_SUITE( MBConvTestCase );
30 CPPUNIT_TEST( WC2CP1250 );
31 CPPUNIT_TEST_SUITE_END();
32
33 void WC2CP1250();
34
35 NO_COPY_CLASS(MBConvTestCase);
36 };
37
38 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" );
39
40 void MBConvTestCase::WC2CP1250()
41 {
42 static const struct Data
43 {
44 const wchar_t *wc;
45 const char *cp1250;
46 } data[] =
47 {
48 { L"hello", "hello" }, // test that it works in simplest case
49 { L"½ of ½ is ¼", "" }, // this should fail as cp1250 doesn't have 1/2
50 };
51
52 wxCSConv cs1250(wxFONTENCODING_CP1250);
53 for ( size_t n = 0; n < WXSIZEOF(data); n++ )
54 {
55 const Data& d = data[n];
56 CPPUNIT_ASSERT( wxString(d.wc, cs1250) == d.cp1250 );
57 }
58 }
59
60 // ----------------------------------------------------------------------------
61 // program entry point
62 // ----------------------------------------------------------------------------
63
64 int main()
65 {
66 CppUnit::TextUi::TestRunner runner;
67 runner.addTest(MBConvTestCase::suite());
68
69 return runner.run("") ? 0 : 1;
70 }
71