added a test for wxTextFile in Unicode

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-09-27 15:27:52 +00:00
parent cc70081166
commit 5bc1deebaa

View File

@@ -93,7 +93,7 @@
#undef TEST_ALL #undef TEST_ALL
static const bool TEST_ALL = true; static const bool TEST_ALL = true;
#else #else
#define TEST_STRINGS #define TEST_UNICODE
static const bool TEST_ALL = false; static const bool TEST_ALL = false;
#endif #endif
@@ -814,8 +814,10 @@ static void TestFileConfRead()
#include "wx/filename.h" #include "wx/filename.h"
static void DumpFileName(const wxFileName& fn) static void DumpFileName(const wxChar *desc, const wxFileName& fn)
{ {
wxPuts(desc);
wxString full = fn.GetFullPath(); wxString full = fn.GetFullPath();
wxString vol, path, name, ext; wxString vol, path, name, ext;
@@ -4206,6 +4208,26 @@ static void TestUnicodeToFromAscii()
wxPutchar(_T('\n')); wxPutchar(_T('\n'));
} }
#include "wx/textfile.h"
static void TestUnicodeTextFileRead()
{
wxPuts(_T("Testing wxTextFile in Unicode build\n"));
wxTextFile file;
if ( file.Open(_T("testdata.fc"), wxConvLocal) )
{
const size_t count = file.GetLineCount();
for ( size_t n = 0; n < count; n++ )
{
const wxString& s = file[n];
wxPrintf(_T("Line %u: \"%s\" (len %u, last char = '%c')\n"),
(unsigned)n, s.c_str(), (unsigned)s.length(), s.Last());
}
}
}
#endif // TEST_UNICODE #endif // TEST_UNICODE
#ifdef TEST_WCHAR #ifdef TEST_WCHAR
@@ -4285,7 +4307,7 @@ static void TestUtf8()
} }
} }
wxString s(wxConvUTF8.cMB2WC((const char *)u8d.text), *wxConvCurrent); wxString s(wxConvUTF8.cMB2WC((const char *)u8d.text));
if ( s.empty() ) if ( s.empty() )
s = _T("<< conversion failed >>"); s = _T("<< conversion failed >>");
wxPrintf(_T("String in current cset: %s\n"), s.c_str()); wxPrintf(_T("String in current cset: %s\n"), s.c_str());
@@ -5945,6 +5967,17 @@ static void TestSemaphore()
typedef unsigned short ushort; typedef unsigned short ushort;
static int MyStringCompare(wxString* s1, wxString* s2)
{
return wxStrcmp(s1->c_str(), s2->c_str());
}
static int MyStringReverseCompare(wxString* s1, wxString* s2)
{
return -wxStrcmp(s1->c_str(), s2->c_str());
}
#define DefineCompare(name, T) \ #define DefineCompare(name, T) \
\ \
int wxCMPFUNC_CONV name ## CompareValues(T first, T second) \ int wxCMPFUNC_CONV name ## CompareValues(T first, T second) \
@@ -7123,16 +7156,15 @@ int main(int argc, char **argv)
#endif // TEST_FILE #endif // TEST_FILE
#ifdef TEST_FILENAME #ifdef TEST_FILENAME
if ( 0 ) if ( 1 )
{ {
wxFileName fn; wxFileName fn(_T("c:\\foo"), _T("bar.baz"));
fn.Assign(_T("c:\\foo"), _T("bar.baz")); DumpFileName(_T("Before Normalize():"), fn);
fn.Assign(_T("/u/os9-port/Viewer/tvision/WEI2HZ-3B3-14_05-04-00MSC1.asc"));
DumpFileName(fn); fn.Normalize();
DumpFileName(_T("After Normalize():"), fn);
} }
TestFileNameConstruction();
if ( TEST_ALL ) if ( TEST_ALL )
{ {
TestFileNameConstruction(); TestFileNameConstruction();
@@ -7288,10 +7320,12 @@ int main(int argc, char **argv)
if ( nCPUs != -1 ) if ( nCPUs != -1 )
wxThread::SetConcurrency(nCPUs); wxThread::SetConcurrency(nCPUs);
TestDetachedThreads(); TestJoinableThreads();
if ( TEST_ALL ) if ( TEST_ALL )
{ {
TestJoinableThreads(); TestJoinableThreads();
TestDetachedThreads();
TestThreadSuspend(); TestThreadSuspend();
TestThreadDelete(); TestThreadDelete();
TestThreadConditions(); TestThreadConditions();
@@ -7326,8 +7360,6 @@ int main(int argc, char **argv)
TestTimeZoneBug(); TestTimeZoneBug();
} }
TestTimeWNumber();
if ( TEST_INTERACTIVE ) if ( TEST_INTERACTIVE )
TestDateTimeInteractive(); TestDateTimeInteractive();
#endif // TEST_DATETIME #endif // TEST_DATETIME
@@ -7351,7 +7383,11 @@ int main(int argc, char **argv)
#endif // TEST_VOLUME #endif // TEST_VOLUME
#ifdef TEST_UNICODE #ifdef TEST_UNICODE
TestUnicodeTextFileRead();
if ( TEST_ALL )
{
TestUnicodeToFromAscii(); TestUnicodeToFromAscii();
}
#endif // TEST_UNICODE #endif // TEST_UNICODE
#ifdef TEST_WCHAR #ifdef TEST_WCHAR