]>
git.saurik.com Git - wxWidgets.git/blob - tests/strings/unicode.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/unicode.cpp
3 // Purpose: Unicode unit test
4 // Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
7 // Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
24 #include "wx/textfile.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class UnicodeTestCase
: public CppUnit::TestCase
36 CPPUNIT_TEST_SUITE( UnicodeTestCase
);
37 CPPUNIT_TEST( ToFromAscii
);
38 CPPUNIT_TEST( TextFileRead
);
39 CPPUNIT_TEST_SUITE_END();
44 DECLARE_NO_COPY_CLASS(UnicodeTestCase
)
47 // register in the unnamed registry so that these tests are run by default
48 CPPUNIT_TEST_SUITE_REGISTRATION( UnicodeTestCase
);
50 // also include in it's own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UnicodeTestCase
, "UnicodeTestCase" );
53 UnicodeTestCase::UnicodeTestCase()
57 void UnicodeTestCase::ToFromAscii()
60 #define TEST_TO_FROM_ASCII(txt) \
62 static const char *msg = txt; \
63 wxString s = wxString::FromAscii(msg); \
64 CPPUNIT_ASSERT( strcmp( s.ToAscii() , msg ) == 0 ); \
67 TEST_TO_FROM_ASCII( "Hello, world!" );
68 TEST_TO_FROM_ASCII( "additional \" special \t test \\ component \n :-)" );
71 void UnicodeTestCase::TextFileRead()
74 bool file_opened
= file
.Open(_T("testdata.fc"), wxConvLocal
);
76 CPPUNIT_ASSERT( file_opened
);
78 static const wxChar
*lines
[6] = {
79 _T("# this is the test data file for wxFileConfig tests"),
81 _T("# a comment here"),
83 _T("value\\ with\\ spaces\\ inside\\ it=nothing special"),
89 const size_t count
= file
.GetLineCount();
90 CPPUNIT_ASSERT( count
== 6 );
91 for ( size_t n
= 0; n
< count
; n
++ )
93 CPPUNIT_ASSERT( wxStrcmp( file
[n
].c_str() , lines
[n
] ) == 0 );