]> git.saurik.com Git - wxWidgets.git/blame - tests/strings/unicode.cpp
really pass the proper output buffer size in wxMBConv_win32 round trip check, at...
[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
387f829e
VS
23// ----------------------------------------------------------------------------
24// test class
25// ----------------------------------------------------------------------------
26
27class UnicodeTestCase : public CppUnit::TestCase
28{
29public:
30 UnicodeTestCase();
31
32private:
33 CPPUNIT_TEST_SUITE( UnicodeTestCase );
34 CPPUNIT_TEST( ToFromAscii );
a65ca3e6
VZ
35#if wxUSE_WCHAR_T
36 CPPUNIT_TEST( ConstructorsWithConversion );
37 CPPUNIT_TEST( Conversion );
38 CPPUNIT_TEST( ConversionUTF7 );
39 CPPUNIT_TEST( ConversionUTF8 );
40#endif // wxUSE_WCHAR_T
387f829e
VS
41 CPPUNIT_TEST_SUITE_END();
42
43 void ToFromAscii();
a65ca3e6
VZ
44#if wxUSE_WCHAR_T
45 void ConstructorsWithConversion();
46 void Conversion();
47 void ConversionUTF7();
48 void ConversionUTF8();
49
50 // test if converting s using the given encoding gives ws and vice versa
51 //
52 // if either of the first 2 arguments is NULL, the conversion is supposed
53 // to fail
54 void DoTestConversion(const char *s, const wchar_t *w, wxCSConv& conv);
55#endif // wxUSE_WCHAR_T
56
387f829e
VS
57
58 DECLARE_NO_COPY_CLASS(UnicodeTestCase)
59};
60
61// register in the unnamed registry so that these tests are run by default
62CPPUNIT_TEST_SUITE_REGISTRATION( UnicodeTestCase );
63
64// also include in it's own registry so that these tests can be run alone
65CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UnicodeTestCase, "UnicodeTestCase" );
66
67UnicodeTestCase::UnicodeTestCase()
68{
69}
70
71void UnicodeTestCase::ToFromAscii()
72{
73
74#define TEST_TO_FROM_ASCII(txt) \
75 { \
76 static const char *msg = txt; \
77 wxString s = wxString::FromAscii(msg); \
78 CPPUNIT_ASSERT( strcmp( s.ToAscii() , msg ) == 0 ); \
79 }
80
81 TEST_TO_FROM_ASCII( "Hello, world!" );
82 TEST_TO_FROM_ASCII( "additional \" special \t test \\ component \n :-)" );
83}
84
a65ca3e6
VZ
85#if wxUSE_WCHAR_T
86void UnicodeTestCase::ConstructorsWithConversion()
87{
88