This page contains the following errors:

error on line 408 at column 150: Premature end of data in tag tr line 407

Below is a rendering of the page up to the first error.

git.saurik.com Git - wxWidgets.git/blame - tests/strings/unicode.cpp
fixed python-related files names after they had been apparently renamed in the cvs...
[wxWidgets.git] / tests / strings / unicode.cpp
CommitLineData
387f829e
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/strings/unicode.cpp
3// Purpose: Unicode unit test
4// Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
5// Created: 2004-04-28
6// RCS-ID: $Id$
7// Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
8899b155 14#include "testprec.h"
387f829e
VS
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
387f829e
VS
21#endif // WX_PRECOMP
22
8da7a00a
VZ
23// ----------------------------------------------------------------------------
24// local functions
25// ----------------------------------------------------------------------------
26
27#if wxUSE_WCHAR_T && !wxUSE_UNICODE
28
29// in case wcscmp is missing
30static int wx_wcscmp(const wchar_t *s1, const wchar_t *s2)
31{
32 while (*s1 == *s2 && *s1 != 0)
33 {
34 s1++;
35 s2++;
36 }
37 return *s1 - *s2;
38}
39
40#endif // wxUSE_WCHAR_T && !wxUSE_UNICODE
41
387f829e
VS
42// ----------------------------------------------------------------------------
43// test class
44// ----------------------------------------------------------------------------
45
46class UnicodeTestCase : public CppUnit::TestCase
47{
48public:
49 UnicodeTestCase();
50
51private:
52 CPPUNIT_TEST_SUITE( UnicodeTestCase );
53 CPPUNIT_TEST( ToFromAscii );
a65ca3e6
VZ
54#if wxUSE_WCHAR_T
55 CPPUNIT_TEST( ConstructorsWithConversion );
5975f198 56 CPPUNIT_TEST( ConversionWithNULs );
a65ca3e6
VZ
57 CPPUNIT_TEST( ConversionUTF7 );
58 CPPUNIT_TEST( ConversionUTF8 );
5975f198 59 CPPUNIT_TEST( ConversionUTF16 );
a7823b26 60 CPPUNIT_TEST( ConversionUTF32 );
a65ca3e6 61#endif // wxUSE_WCHAR_T
387f829e
VS
62 CPPUNIT_TEST_SUITE_END();
63
64 void ToFromAscii();
a65ca3e6
VZ
65#if wxUSE_WCHAR_T
66 void ConstructorsWithConversion();
5975f198 67 void ConversionWithNULs();
a65ca3e6
VZ
68 void ConversionUTF7();
69 void ConversionUTF8();
5975f198 70 void ConversionUTF16();
a7823b26 71 void ConversionUTF32();
a65ca3e6
VZ
72
73 // test if converting s using the given encoding gives ws and vice versa
74 //
75 // if either of the first 2 arguments is NULL, the conversion is supposed
76 // to fail
b0441359 77 void DoTestConversion(const char *s, const wchar_t *w, wxMBConv& conv);
a65ca3e6
VZ
78#endif // wxUSE_WCHAR_T
79
387f829e
VS
80
81 DECLARE_NO_COPY_CLASS(UnicodeTestCase)
82};
83
84// register in the unnamed registry so that these tests are run by default
85CPPUNIT_TEST_SUITE_REGISTRATION( UnicodeTestCase );
86
87// also include in it's own registry so that these tests can be run alone
1fc9e0d3 88CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UnicodeTestCase, "Unicode" );
387f829e
VS
89
90UnicodeTestCase::UnicodeTestCase()
91{
92}
93
94void UnicodeTestCase::ToFromAscii()
95{
96
97#define TEST_TO_FROM_ASCII(txt) \
98 { \
99 static const char *msg = txt; \
100 wxString s = wxString::FromAscii(msg); \
101 CPPUNIT_ASSERT( strcmp( s.ToAscii() , msg ) == 0 ); \
102 }
103
104 TEST_TO_FROM_ASCII( "Hello, world!" );
105 TEST_TO_FROM_ASCII( "additional \" special \t test \\ component \n :-)" );
106}
107
a65ca3e6
VZ
108#if wxUSE_WCHAR_T
109void UnicodeTestCase::ConstructorsWithConversion()
110{
111