- for ( size_t n = 0; n < WXSIZEOF(langStrings); n++ )
- {
- const wxChar *langStr = langStrings[n];
- if ( langStr )
- {
- // FIXME: this doesn't do anything at all under Windows, we need
- // to create a new wxLocale!
- wxSetEnv(_T("LC_ALL"), langStr);
- }
-
- int lang = gs_localeDefault.GetSystemLanguage();
- wxPrintf(_T("Locale for '%s' is %s.\n"),
- langStr ? langStr : _T("system default"), GetLangName(lang));
- }
-}
-
-#endif // TEST_LOCALE
-
-// ----------------------------------------------------------------------------
-// MIME types
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_MIME
-
-#include "wx/mimetype.h"
-
-static void TestMimeEnum()
-{
- wxPuts(_T("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
-
- wxArrayString mimetypes;
-
- size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
-
- wxPrintf(_T("*** All %u known filetypes: ***\n"), count);
-
- wxArrayString exts;
- wxString desc;
-
- for ( size_t n = 0; n < count; n++ )
- {
- wxFileType *filetype =
- wxTheMimeTypesManager->GetFileTypeFromMimeType(mimetypes[n]);
- if ( !filetype )
- {
- wxPrintf(_T("nothing known about the filetype '%s'!\n"),
- mimetypes[n].c_str());
- continue;
- }
-
- filetype->GetDescription(&desc);
- filetype->GetExtensions(exts);
-
- filetype->GetIcon(NULL);
-
- wxString extsAll;
- for ( size_t e = 0; e < exts.GetCount(); e++ )
- {
- if ( e > 0 )
- extsAll << _T(", ");
- extsAll += exts[e];
- }
-
- wxPrintf(_T("\t%s: %s (%s)\n"),
- mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
- }
-
- wxPuts(wxEmptyString);
-}
-
-static void TestMimeOverride()
-{
- wxPuts(_T("*** Testing wxMimeTypesManager additional files loading ***\n"));
-
- static const wxChar *mailcap = _T("/tmp/mailcap");
- static const wxChar *mimetypes = _T("/tmp/mime.types");
-
- if ( wxFile::Exists(mailcap) )
- wxPrintf(_T("Loading mailcap from '%s': %s\n"),
- mailcap,
- wxTheMimeTypesManager->ReadMailcap(mailcap) ? _T("ok") : _T("ERROR"));
- else
- wxPrintf(_T("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
- mailcap);
-
- if ( wxFile::Exists(mimetypes) )
- wxPrintf(_T("Loading mime.types from '%s': %s\n"),
- mimetypes,
- wxTheMimeTypesManager->ReadMimeTypes(mimetypes) ? _T("ok") : _T("ERROR"));
- else
- wxPrintf(_T("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
- mimetypes);
-
- wxPuts(wxEmptyString);
-}
-
-static void TestMimeFilename()
-{
- wxPuts(_T("*** Testing MIME type from filename query ***\n"));
-
- static const wxChar *filenames[] =
- {
- _T("readme.txt"),
- _T("document.pdf"),
- _T("image.gif"),
- _T("picture.jpeg"),
- };
-
- for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
- {
- const wxString fname = filenames[n];
- wxString ext = fname.AfterLast(_T('.'));
- wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
- if ( !ft )
- {
- wxPrintf(_T("WARNING: extension '%s' is unknown.\n"), ext.c_str());
- }
- else
- {
- wxString desc;
- if ( !ft->GetDescription(&desc) )
- desc = _T("<no description>");
-
- wxString cmd;
- if ( !ft->GetOpenCommand(&cmd,
- wxFileType::MessageParameters(fname, wxEmptyString)) )
- cmd = _T("<no command available>");
- else
- cmd = wxString(_T('"')) + cmd + _T('"');
-
- wxPrintf(_T("To open %s (%s) do %s.\n"),
- fname.c_str(), desc.c_str(), cmd.c_str());
-
- delete ft;
- }
- }
-
- wxPuts(wxEmptyString);
-}
-
-static void TestMimeAssociate()
-{
- wxPuts(_T("*** Testing creation of filetype association ***\n"));
-
- wxFileTypeInfo ftInfo(
- _T("application/x-xyz"),
- _T("xyzview '%s'"), // open cmd
- _T(""), // print cmd
- _T("XYZ File"), // description
- _T(".xyz"), // extensions
- NULL // end of extensions
- );
- ftInfo.SetShortDesc(_T("XYZFile")); // used under Win32 only
-
- wxFileType *ft = wxTheMimeTypesManager->Associate(ftInfo);
- if ( !ft )
- {
- wxPuts(_T("ERROR: failed to create association!"));
- }
- else
- {
- // TODO: read it back
- delete ft;
- }
-
- wxPuts(wxEmptyString);
-}
-
-#endif // TEST_MIME
-
-// ----------------------------------------------------------------------------
-// misc information functions
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_INFO_FUNCTIONS
-
-#include "wx/utils.h"
-
-static void TestDiskInfo()
-{
- wxPuts(_T("*** Testing wxGetDiskSpace() ***"));
-
- for ( ;; )
- {
- wxChar pathname[128];
- wxPrintf(_T("\nEnter a directory name: "));
- if ( !wxFgets(pathname, WXSIZEOF(pathname), stdin) )
- break;
-
- // kill the last '\n'
- pathname[wxStrlen(pathname) - 1] = 0;
-
- wxLongLong total, free;
- if ( !wxGetDiskSpace(pathname, &total, &free) )
- {
- wxPuts(_T("ERROR: wxGetDiskSpace failed."));
- }
- else
- {
- wxPrintf(_T("%sKb total, %sKb free on '%s'.\n"),
- (total / 1024).ToString().c_str(),
- (free / 1024).ToString().c_str(),
- pathname);
- }
- }
-}
-
-static void TestOsInfo()
-{
- wxPuts(_T("*** Testing OS info functions ***\n"));
-
- int major, minor;
- wxGetOsVersion(&major, &minor);
- wxPrintf(_T("Running under: %s, version %d.%d\n"),
- wxGetOsDescription().c_str(), major, minor);
-
- wxPrintf(_T("%ld free bytes of memory left.\n"), wxGetFreeMemory());
-
- wxPrintf(_T("Host name is %s (%s).\n"),
- wxGetHostName().c_str(), wxGetFullHostName().c_str());
-
- wxPuts(wxEmptyString);
-}
-
-static void TestUserInfo()
-{
- wxPuts(_T("*** Testing user info functions ***\n"));
-
- wxPrintf(_T("User id is:\t%s\n"), wxGetUserId().c_str());
- wxPrintf(_T("User name is:\t%s\n"), wxGetUserName().c_str());
- wxPrintf(_T("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
- wxPrintf(_T("Email address:\t%s\n"), wxGetEmailAddress().c_str());
-
- wxPuts(wxEmptyString);
-}
-
-#endif // TEST_INFO_FUNCTIONS
-
-// ----------------------------------------------------------------------------
-// long long
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_LONGLONG
-
-#include "wx/longlong.h"
-#include "wx/timer.h"
-
-// make a 64 bit number from 4 16 bit ones
-#define MAKE_LL(x1, x2, x3, x4) wxLongLong((x1 << 16) | x2, (x3 << 16) | x3)
-
-// get a random 64 bit number
-#define RAND_LL() MAKE_LL(rand(), rand(), rand(), rand())
-
-static const long testLongs[] =
-{
- 0,
- 1,
- -1,
- LONG_MAX,
- LONG_MIN,
- 0x1234,
- -0x1234
-};
-
-#if wxUSE_LONGLONG_WX
-inline bool operator==(const wxLongLongWx& a, const wxLongLongNative& b)
- { return a.GetHi() == b.GetHi() && a.GetLo() == b.GetLo(); }
-inline bool operator==(const wxLongLongNative& a, const wxLongLongWx& b)
- { return a.GetHi() == b.GetHi() && a.GetLo() == b.GetLo(); }
-#endif // wxUSE_LONGLONG_WX
-
-#if 0
-static void TestSpeed()
-{
- static const long max = 100000000;
- long n;
-
- {
- wxStopWatch sw;
-
- long l = 0;
- for ( n = 0; n < max; n++ )
- {
- l += n;
- }
- wxUnusedVar(l);
-
- wxPrintf(_T("Summing longs took %ld milliseconds.\n"), sw.Time());
- }
-
-#if wxUSE_LONGLONG_NATIVE
- {
- wxStopWatch sw;
-
- wxLongLong_t l = 0;
- for ( n = 0; n < max; n++ )
- {
- l += n;
- }
- wxUnusedVar(l);
-
- wxPrintf(_T("Summing wxLongLong_t took %ld milliseconds.\n"), sw.Time());
- }
-#endif // wxUSE_LONGLONG_NATIVE
-
- {
- wxStopWatch sw;
-
- wxLongLong l;
- for ( n = 0; n < max; n++ )
- {
- l += n;
- }
-
- wxPrintf(_T("Summing wxLongLongs took %ld milliseconds.\n"), sw.Time());
- }
-}
-#endif
-
-static void TestLongLongConversion()
-{
- wxPuts(_T("*** Testing wxLongLong conversions ***\n"));
-
- size_t nTested = 0;
- for ( size_t n = 0; n < 100000; n++ )
- {
-#if wxUSE_LONGLONG_NATIVE
- wxLongLong a = RAND_LL();
-
- wxLongLongNative b(a.GetHi(), a.GetLo());
-
- if( a != b)
- wxPuts( _T("conversions failure") );
-#else
- wxPuts(_T("Can't do it without native long long type, test skipped."));
-
- return;
-#endif // wxUSE_LONGLONG_NATIVE
-
- if ( !(nTested % 1000) )
- {
- wxPutchar('.');
- fflush(stdout);
- }
-
- nTested++;
- }
-
- wxPuts(_T(" done!"));
-}
-
-static void TestMultiplication()
-{
- wxPuts(_T("*** Testing wxLongLong multiplication ***\n"));
-
- size_t nTested = 0;
- for ( size_t n = 0; n < 100000; n++ )
- {
-#if wxUSE_LONGLONG_NATIVE
- wxLongLong a = RAND_LL();
- wxLongLong b = RAND_LL();
-
- wxLongLongNative aa(a.GetHi(), a.GetLo());
- wxLongLongNative bb(b.GetHi(), b.GetLo());
-
- if( a*b != aa*bb )
- wxPuts( _T("multiplication failure") );
-#else // !wxUSE_LONGLONG_NATIVE
- wxPuts(_T("Can't do it without native long long type, test skipped."));
-
- return;
-#endif // wxUSE_LONGLONG_NATIVE
-
- if ( !(nTested % 1000) )
- {
- wxPutchar('.');
- fflush(stdout);
- }
-
- nTested++;
- }
-
- wxPuts(_T(" done!"));
-}
-
-static void TestDivision()
-{
- wxPuts(_T("*** Testing wxLongLong division ***\n"));
-
- wxLongLong q, r;
- size_t nTested = 0;
- for ( size_t n = 0; n < 100000; n++ )
- {
- // get a random wxLongLong (shifting by 12 the MSB ensures that the
- // multiplication will not overflow)
- wxLongLong ll = MAKE_LL((rand() >> 12), rand(), rand(), rand());
-
- // get a random (but non null) long (not wxLongLong for now) to divide
- // it with
- long l;
- do
- {
- l = rand();
- }
- while ( !l );
-
- q = ll / l;
- r = ll % l;
-
-#if wxUSE_LONGLONG_NATIVE
- wxLongLongNative m(ll.GetHi(), ll.GetLo());
-
- wxLongLongNative p = m / l, s = m % l;
-
- if(q != p || r != s)
- wxPuts( _T("division failure") );
-#else // !wxUSE_LONGLONG_NATIVE
- // verify the result
- wxASSERT_MSG( ll == q*l + r, "division failure" );
-#endif // wxUSE_LONGLONG_NATIVE
-
- if ( !(nTested % 1000) )
- {
- wxPutchar('.');
- fflush(stdout);
- }
-
- nTested++;
- }
-
- wxPuts(_T(" done!"));
-}
-
-static void TestAddition()
-{
- wxPuts(_T("*** Testing wxLongLong addition ***\n"));
-
- wxLongLong a, b, c;
- size_t nTested = 0;
- for ( size_t n = 0; n < 100000; n++ )
- {
- a = RAND_LL();
- b = RAND_LL();
- c = a + b;
-
-#if wxUSE_LONGLONG_NATIVE
- wxASSERT_MSG( c == wxLongLongNative(a.GetHi(), a.GetLo()) +
- wxLongLongNative(b.GetHi(), b.GetLo()),
- _T("addition failure") );
-#else // !wxUSE_LONGLONG_NATIVE
- wxASSERT_MSG( c - b == a, "addition failure" );
-#endif // wxUSE_LONGLONG_NATIVE
-
- if ( !(nTested % 1000) )
- {
- wxPutchar('.');
- fflush(stdout);
- }
-
- nTested++;
- }
-
- wxPuts(_T(" done!"));
-}
-
-static void TestBitOperations()
-{
- wxPuts(_T("*** Testing wxLongLong bit operation ***\n"));
-
- wxLongLong ll;
- size_t nTested = 0;
- for ( size_t n = 0; n < 100000; n++ )
- {
- ll = RAND_LL();
-
-#if wxUSE_LONGLONG_NATIVE
- for ( size_t n = 0; n < 33; n++ )
- {
- }
-#else // !wxUSE_LONGLONG_NATIVE
- wxPuts(_T("Can't do it without native long long type, test skipped."));
-
- return;
-#endif // wxUSE_LONGLONG_NATIVE
-
- if ( !(nTested % 1000) )
- {
- wxPutchar('.');
- fflush(stdout);
- }
-
- nTested++;
- }
-
- wxPuts(_T(" done!"));
-}
-
-static void TestLongLongComparison()
-{
-#if wxUSE_LONGLONG_WX
- wxPuts(_T("*** Testing wxLongLong comparison ***\n"));
-
- static const long ls[2] =
- {
- 0x1234,
- -0x1234,
- };
-
- wxLongLongWx lls[2];
- lls[0] = ls[0];
- lls[1] = ls[1];
-
- for ( size_t n = 0; n < WXSIZEOF(testLongs); n++ )
- {
- bool res;
-
- for ( size_t m = 0; m < WXSIZEOF(lls); m++ )
- {
- res = lls[m] > testLongs[n];
- wxPrintf(_T("0x%lx > 0x%lx is %s (%s)\n"),
- ls[m], testLongs[n], res ? "true" : "false",
- res == (ls[m] > testLongs[n]) ? "ok" : "ERROR");
-
- res = lls[m] < testLongs[n];
- wxPrintf(_T("0x%lx < 0x%lx is %s (%s)\n"),
- ls[m], testLongs[n], res ? "true" : "false",
- res == (ls[m] < testLongs[n]) ? "ok" : "ERROR");
-
- res = lls[m] == testLongs[n];
- wxPrintf(_T("0x%lx == 0x%lx is %s (%s)\n"),
- ls[m], testLongs[n], res ? "true" : "false",
- res == (ls[m] == testLongs[n]) ? "ok" : "ERROR");
- }
- }
-#endif // wxUSE_LONGLONG_WX
-}
-
-static void TestLongLongToString()
-{
- wxPuts(_T("*** Testing wxLongLong::ToString() ***\n"));
-
- for ( size_t n = 0; n < WXSIZEOF(testLongs); n++ )
- {
- wxLongLong ll = testLongs[n];
- wxPrintf(_T("%ld == %s\n"), testLongs[n], ll.ToString().c_str());
- }
-
- wxLongLong ll(0x12345678, 0x87654321);
- wxPrintf(_T("0x1234567887654321 = %s\n"), ll.ToString().c_str());
-
- ll.Negate();
- wxPrintf(_T("-0x1234567887654321 = %s\n"), ll.ToString().c_str());
-}
-
-static void TestLongLongPrintf()
-{
- wxPuts(_T("*** Testing wxLongLong printing ***\n"));
-
-#ifdef wxLongLongFmtSpec
-#ifndef __MINGW32__
- wxLongLong ll = wxLL(0x1234567890abcdef);
- wxString s = wxString::Format(_T("%") wxLongLongFmtSpec _T("x"), ll);
-#else
- wxString s = _T("MinGW compiler does not allow wxLongLong in '...'");
-#endif
- wxPrintf(_T("0x1234567890abcdef -> %s (%s)\n"),
- s.c_str(), s == _T("1234567890abcdef") ? _T("ok") : _T("ERROR"));
-#else // !wxLongLongFmtSpec
- #error "wxLongLongFmtSpec not defined for this compiler/platform"
-#endif
-}
-
-#undef MAKE_LL
-#undef RAND_LL
-
-#endif // TEST_LONGLONG
-
-// ----------------------------------------------------------------------------
-// path list
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_PATHLIST
-
-#ifdef __UNIX__
- #define CMD_IN_PATH _T("ls")
-#else
- #define CMD_IN_PATH _T("command.com")
-#endif
-
-static void TestPathList()
-{
- wxPuts(_T("*** Testing wxPathList ***\n"));
-
- wxPathList pathlist;
- pathlist.AddEnvList(_T("PATH"));
- wxString path = pathlist.FindValidPath(CMD_IN_PATH);
- if ( path.empty() )
- {
- wxPrintf(_T("ERROR: command not found in the path.\n"));
- }
- else
- {
- wxPrintf(_T("Command found in the path as '%s'.\n"), path.c_str());
- }
-}
-
-#endif // TEST_PATHLIST
-
-// ----------------------------------------------------------------------------
-// regular expressions
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_REGEX
-
-#include "wx/regex.h"
-
-static void TestRegExCompile()
-{
- wxPuts(_T("*** Testing RE compilation ***\n"));
-
- static struct RegExCompTestData
- {
- const wxChar *pattern;
- bool correct;
- } regExCompTestData[] =
- {
- { _T("foo"), true },
- { _T("foo("), false },
- { _T("foo(bar"), false },
- { _T("foo(bar)"), true },
- { _T("foo["), false },
- { _T("foo[bar"), false },
- { _T("foo[bar]"), true },
- { _T("foo{"), true },
- { _T("foo{1"), false },
- { _T("foo{bar"), true },
- { _T("foo{1}"), true },
- { _T("foo{1,2}"), true },
- { _T("foo{bar}"), true },
- { _T("foo*"), true },
- { _T("foo**"), false },
- { _T("foo+"), true },
- { _T("foo++"), false },
- { _T("foo?"), true },
- { _T("foo??"), false },
- { _T("foo?+"), false },
- };
-
- wxRegEx re;
- for ( size_t n = 0; n < WXSIZEOF(regExCompTestData); n++ )
- {
- const RegExCompTestData& data = regExCompTestData[n];
- bool ok = re.Compile(data.pattern);
-
- wxPrintf(_T("'%s' is %sa valid RE (%s)\n"),
- data.pattern,
- ok ? wxEmptyString : _T("not "),
- ok == data.correct ? _T("ok") : _T("ERROR"));
- }
-}
-
-static void TestRegExMatch()
-{
- wxPuts(_T("*** Testing RE matching ***\n"));
-
- static struct RegExMatchTestData
- {
- const wxChar *pattern;
- const wxChar *text;
- bool correct;
- } regExMatchTestData[] =
- {
- { _T("foo"), _T("bar"), false },
- { _T("foo"), _T("foobar"), true },
- { _T("^foo"), _T("foobar"), true },
- { _T("^foo"), _T("barfoo"), false },
- { _T("bar$"), _T("barbar"), true },
- { _T("bar$"), _T("barbar "), false },
- };
-
- for ( size_t n = 0; n < WXSIZEOF(regExMatchTestData); n++ )
- {
- const RegExMatchTestData& data = regExMatchTestData[n];
-
- wxRegEx re(data.pattern);
- bool ok = re.Matches(data.text);
-
- wxPrintf(_T("'%s' %s %s (%s)\n"),
- data.pattern,
- ok ? _T("matches") : _T("doesn't match"),
- data.text,
- ok == data.correct ? _T("ok") : _T("ERROR"));
- }
-}
-
-static void TestRegExSubmatch()
-{
- wxPuts(_T("*** Testing RE subexpressions ***\n"));
-
- wxRegEx re(_T("([[:alpha:]]+) ([[:alpha:]]+) ([[:digit:]]+).*([[:digit:]]+)$"));
- if ( !re.IsValid() )
- {
- wxPuts(_T("ERROR: compilation failed."));
- return;
- }
-
- wxString text = _T("Fri Jul 13 18:37:52 CEST 2001");
-
- if ( !re.Matches(text) )
- {
- wxPuts(_T("ERROR: match expected."));
- }
- else
- {
- wxPrintf(_T("Entire match: %s\n"), re.GetMatch(text).c_str());
-
- wxPrintf(_T("Date: %s/%s/%s, wday: %s\n"),
- re.GetMatch(text, 3).c_str(),
- re.GetMatch(text, 2).c_str(),
- re.GetMatch(text, 4).c_str(),
- re.GetMatch(text, 1).c_str());
- }
-}
-
-static void TestRegExReplacement()
-{
- wxPuts(_T("*** Testing RE replacement ***"));
-
- static struct RegExReplTestData
- {
- const wxChar *text;
- const wxChar *repl;
- const wxChar *result;
- size_t count;
- } regExReplTestData[] =
- {
- { _T("foo123"), _T("bar"), _T("bar"), 1 },
- { _T("foo123"), _T("\\2\\1"), _T("123foo"), 1 },
- { _T("foo_123"), _T("\\2\\1"), _T("123foo"), 1 },
- { _T("123foo"), _T("bar"), _T("123foo"), 0 },
- { _T("123foo456foo"), _T("&&"), _T("123foo456foo456foo"), 1 },
- { _T("foo123foo123"), _T("bar"), _T("barbar"), 2 },
- { _T("foo123_foo456_foo789"), _T("bar"), _T("bar_bar_bar"), 3 },
- };
-
- const wxChar *pattern = _T("([a-z]+)[^0-9]*([0-9]+)");
- wxRegEx re(pattern);
-
- wxPrintf(_T("Using pattern '%s' for replacement.\n"), pattern);
-
- for ( size_t n = 0; n < WXSIZEOF(regExReplTestData); n++ )
- {
- const RegExReplTestData& data = regExReplTestData[n];
-
- wxString text = data.text;
- size_t nRepl = re.Replace(&text, data.repl);
-
- wxPrintf(_T("%s =~ s/RE/%s/g: %u match%s, result = '%s' ("),
- data.text, data.repl,
- nRepl, nRepl == 1 ? wxEmptyString : _T("es"),
- text.c_str());
- if ( text == data.result && nRepl == data.count )
- {
- wxPuts(_T("ok)"));
- }
- else
- {
- wxPrintf(_T("ERROR: should be %u and '%s')\n"),
- data.count, data.result);
- }
- }
-}
-
-static void TestRegExInteractive()
-{
- wxPuts(_T("*** Testing RE interactively ***"));
-
- for ( ;; )
- {
- wxChar pattern[128];
- wxPrintf(_T("\nEnter a pattern: "));
- if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
- break;
-
- // kill the last '\n'
- pattern[wxStrlen(pattern) - 1] = 0;
-
- wxRegEx re;
- if ( !re.Compile(pattern) )
- {
- continue;
- }
-
- wxChar text[128];
- for ( ;; )
- {
- wxPrintf(_T("Enter text to match: "));
- if ( !wxFgets(text, WXSIZEOF(text), stdin) )
- break;
-
- // kill the last '\n'
- text[wxStrlen(text) - 1] = 0;
-
- if ( !re.Matches(text) )
- {
- wxPrintf(_T("No match.\n"));
- }
- else
- {
- wxPrintf(_T("Pattern matches at '%s'\n"), re.GetMatch(text).c_str());
-
- size_t start, len;
- for ( size_t n = 1; ; n++ )
- {
- if ( !re.GetMatch(&start, &len, n) )
- {
- break;
- }
-
- wxPrintf(_T("Subexpr %u matched '%s'\n"),
- n, wxString(text + start, len).c_str());
- }
- }
- }
- }
-}
-
-#endif // TEST_REGEX
-
-// ----------------------------------------------------------------------------
-// database
-// ----------------------------------------------------------------------------
-
-#if !wxUSE_ODBC
- #undef TEST_ODBC
-#endif
-
-#ifdef TEST_ODBC
-
-#include <wx/db.h>
-
-static void TestDbOpen()
-{
- HENV henv;
- wxDb db(henv);
-}
-
-#endif // TEST_ODBC
-
-// ----------------------------------------------------------------------------
-// printf() tests
-// ----------------------------------------------------------------------------
-
-/*
- NB: this stuff was taken from the glibc test suite and modified to build
- in wxWindows: if I read the copyright below properly, this shouldn't
- be a problem
- */
-
-#ifdef TEST_PRINTF
-
-#ifdef wxTEST_PRINTF
- // use our functions from wxchar.cpp
- #undef wxPrintf
- #undef wxSprintf
-
- // NB: do _not_ use ATTRIBUTE_PRINTF here, we have some invalid formats
- // in the tests below
- int wxPrintf( const wxChar *format, ... );
- int wxSprintf( wxChar *str, const wxChar *format, ... );
-#endif
-
-#include "wx/longlong.h"
-
-#include <float.h>
-
-static void rfg1 (void);
-static void rfg2 (void);
-
-
-static void
-fmtchk (const wxChar *fmt)
-{
- (void) wxPrintf(_T("%s:\t`"), fmt);
- (void) wxPrintf(fmt, 0x12);
- (void) wxPrintf(_T("'\n"));
-}
-
-static void
-fmtst1chk (const wxChar *fmt)
-{
- (void) wxPrintf(_T("%s:\t`"), fmt);
- (void) wxPrintf(fmt, 4, 0x12);
- (void) wxPrintf(_T("'\n"));
-}
-
-static void
-fmtst2chk (const wxChar *fmt)
-{
- (void) wxPrintf(_T("%s:\t`"), fmt);
- (void) wxPrintf(fmt, 4, 4, 0x12);
- (void) wxPrintf(_T("'\n"));
-}
-
-/* This page is covered by the following copyright: */
-
-/* (C) Copyright C E Chew
- *
- * Feel free to copy, use and distribute this software provided:
- *
- * 1. you do not pretend that you wrote it
- * 2. you leave this copyright notice intact.
- */
-
-/*
- * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
- */
-
-#define DEC -123
-#define INT 255
-#define UNS (~0)
-
-/* Formatted Output Test
- *
- * This exercises the output formatting code.
- */
-
-wxChar *PointerNull = NULL;
-
-static void
-fp_test (void)
-{
- int i, j, k, l;
- wxChar buf[7];
- wxChar *prefix = buf;
- wxChar tp[20];
-
- wxPuts(_T("\nFormatted output test"));
- wxPrintf(_T("prefix 6d 6o 6x 6X 6u\n"));
- wxStrcpy(prefix, _T("%"));
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
- for (k = 0; k < 2; k++) {
- for (l = 0; l < 2; l++) {
- wxStrcpy(prefix, _T("%"));
- if (i == 0) wxStrcat(prefix, _T("-"));
- if (j == 0) wxStrcat(prefix, _T("+"));
- if (k == 0) wxStrcat(prefix, _T("#"));
- if (l == 0) wxStrcat(prefix, _T("0"));
- wxPrintf(_T("%5s |"), prefix);
- wxStrcpy(tp, prefix);
- wxStrcat(tp, _T("6d |"));
- wxPrintf(tp, DEC);
- wxStrcpy(tp, prefix);
- wxStrcat(tp, _T("6o |"));
- wxPrintf(tp, INT);
- wxStrcpy(tp, prefix);
- wxStrcat(tp, _T("6x |"));
- wxPrintf(tp, INT);
- wxStrcpy(tp, prefix);
- wxStrcat(tp, _T("6X |"));
- wxPrintf(tp, INT);
- wxStrcpy(tp, prefix);
- wxStrcat(tp, _T("6u |"));
- wxPrintf(tp, UNS);
- wxPrintf(_T("\n"));
- }
- }
- }
- }
- wxPrintf(_T("%10s\n"), PointerNull);
- wxPrintf(_T("%-10s\n"), PointerNull);
-}
-
-static void TestPrintf()
-{
- static wxChar shortstr[] = _T("Hi, Z.");
- static wxChar longstr[] = _T("Good morning, Doctor Chandra. This is Hal. \
-I am ready for my first lesson today.");
- int result = 0;
- wxString test_format;
-
- fmtchk(_T("%.4x"));
- fmtchk(_T("%04x"));
- fmtchk(_T("%4.4x"));
- fmtchk(_T("%04.4x"));
- fmtchk(_T("%4.3x"));
- fmtchk(_T("%04.3x"));
-
- fmtst1chk(_T("%.*x"));
- fmtst1chk(_T("%0*x"));
- fmtst2chk(_T("%*.*x"));
- fmtst2chk(_T("%0*.*x"));
-
- wxString bad_format = _T("bad format:\t\"%b\"\n");
- wxPrintf(bad_format.c_str());
- wxPrintf(_T("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL);
-
- wxPrintf(_T("decimal negative:\t\"%d\"\n"), -2345);
- wxPrintf(_T("octal negative:\t\"%o\"\n"), -2345);
- wxPrintf(_T("hex negative:\t\"%x\"\n"), -2345);
- wxPrintf(_T("long decimal number:\t\"%ld\"\n"), -123456L);
- wxPrintf(_T("long octal negative:\t\"%lo\"\n"), -2345L);
- wxPrintf(_T("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
- wxPrintf(_T("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
- test_format = _T("left-adjusted ZLDN:\t\"%-010ld\"\n");
- wxPrintf(test_format.c_str(), -123456);
- wxPrintf(_T("space-padded LDN:\t\"%10ld\"\n"), -123456L);
- wxPrintf(_T("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
-
- test_format = _T("zero-padded string:\t\"%010s\"\n");
- wxPrintf(test_format.c_str(), shortstr);
- test_format = _T("left-adjusted Z string:\t\"%-010s\"\n");
- wxPrintf(test_format.c_str(), shortstr);
- wxPrintf(_T("space-padded string:\t\"%10s\"\n"), shortstr);
- wxPrintf(_T("left-adjusted S string:\t\"%-10s\"\n"), shortstr);
- wxPrintf(_T("null string:\t\"%s\"\n"), PointerNull);
- wxPrintf(_T("limited string:\t\"%.22s\"\n"), longstr);
-
- wxPrintf(_T("e-style >= 1:\t\"%e\"\n"), 12.34);
- wxPrintf(_T("e-style >= .1:\t\"%e\"\n"), 0.1234);
- wxPrintf(_T("e-style < .1:\t\"%e\"\n"), 0.001234);
- wxPrintf(_T("e-style big:\t\"%.60e\"\n"), 1e20);
- wxPrintf(_T("e-style == .1:\t\"%e\"\n"), 0.1);
- wxPrintf(_T("f-style >= 1:\t\"%f\"\n"), 12.34);
- wxPrintf(_T("f-style >= .1:\t\"%f\"\n"), 0.1234);
- wxPrintf(_T("f-style < .1:\t\"%f\"\n"), 0.001234);
- wxPrintf(_T("g-style >= 1:\t\"%g\"\n"), 12.34);
- wxPrintf(_T("g-style >= .1:\t\"%g\"\n"), 0.1234);
- wxPrintf(_T("g-style < .1:\t\"%g\"\n"), 0.001234);
- wxPrintf(_T("g-style big:\t\"%.60g\"\n"), 1e20);
-
- wxPrintf (_T(" %6.5f\n"), .099999999860301614);
- wxPrintf (_T(" %6.5f\n"), .1);
- wxPrintf (_T("x%5.4fx\n"), .5);
-
- wxPrintf (_T("%#03x\n"), 1);
-
- //wxPrintf (_T("something really insane: %.10000f\n"), 1.0);
-
- {
- double d = FLT_MIN;
- int niter = 17;
-
- while (niter-- != 0)
- wxPrintf (_T("%.17e\n"), d / 2);
- fflush (stdout);
- }
-
-#ifndef __WATCOMC__
- // Open Watcom cause compiler error here
- // Error! E173: col(24) floating-point constant too small to represent
- wxPrintf (_T("%15.5e\n"), 4.9406564584124654e-324);
-#endif
-
-#define FORMAT _T("|%12.4f|%12.4e|%12.4g|\n")
- wxPrintf (FORMAT, 0.0, 0.0, 0.0);
- wxPrintf (FORMAT, 1.0, 1.0, 1.0);
- wxPrintf (FORMAT, -1.0, -1.0, -1.0);
- wxPrintf (FORMAT, 100.0, 100.0, 100.0);
- wxPrintf (FORMAT, 1000.0, 1000.0, 1000.0);
- wxPrintf (FORMAT, 10000.0, 10000.0, 10000.0);
- wxPrintf (FORMAT, 12345.0, 12345.0, 12345.0);
- wxPrintf (FORMAT, 100000.0, 100000.0, 100000.0);
- wxPrintf (FORMAT, 123456.0, 123456.0, 123456.0);
-#undef FORMAT
-
- {
- wxChar buf[20];
- int rc = wxSnprintf (buf, WXSIZEOF(buf), _T("%30s"), _T("foo"));
-
- wxPrintf(_T("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
- rc, WXSIZEOF(buf), buf);
-#if 0
- wxChar buf2[512];
- wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
- wxSnprintf(buf2, WXSIZEOFbuf2), "%.999999u", 10));
-#endif
- }
-
- fp_test ();
-
- wxPrintf (_T("%e should be 1.234568e+06\n"), 1234567.8);
- wxPrintf (_T("%f should be 1234567.800000\n"), 1234567.8);
- wxPrintf (_T("%g should be 1.23457e+06\n"), 1234567.8);
- wxPrintf (_T("%g should be 123.456\n"), 123.456);
- wxPrintf (_T("%g should be 1e+06\n"), 1000000.0);
- wxPrintf (_T("%g should be 10\n"), 10.0);
- wxPrintf (_T("%g should be 0.02\n"), 0.02);
-
- {
- double x=1.0;
- wxPrintf(_T("%.17f\n"),(1.0/x/10.0+1.0)*x-x);
- }
-
- {
- wxChar buf[200];
-
- wxSprintf(buf,_T("%*s%*s%*s"),-1,_T("one"),-20,_T("two"),-30,_T("three"));
-
- result |= wxStrcmp (buf,
- _T("onetwo three "));
-
- wxPuts (result != 0 ? _T("Test failed!") : _T("Test ok."));
- }
-
-#ifdef wxLongLong_t
- {
- wxChar buf[200];
-
- wxSprintf(buf, _T("%07") wxLongLongFmtSpec _T("o"), wxLL(040000000000));
- #if 0
- // for some reason below line fails under Borland
- wxPrintf (_T("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf);
- #endif
-
- if (wxStrcmp (buf, _T("40000000000")) != 0)
- {
- result = 1;
- wxPuts (_T("\tFAILED"));
- }
- wxUnusedVar(result);
- wxPuts (wxEmptyString);
- }
-#endif // wxLongLong_t
-
- wxPrintf (_T("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX + 2, UCHAR_MAX + 2);
- wxPrintf (_T("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX + 2, USHRT_MAX + 2);
-
- wxPuts (_T("--- Should be no further output. ---"));
- rfg1 ();
- rfg2 ();
-
-#if 0
- {
- wxChar bytes[7];
- wxChar buf[20];
-
- memset (bytes, '\xff', sizeof bytes);
- wxSprintf (buf, _T("foo%hhn\n"), &bytes[3]);
- if (bytes[0] != '\xff' || bytes[1] != '\xff' || bytes[2] != '\xff'
- || bytes[4] != '\xff' || bytes[5] != '\xff' || bytes[6] != '\xff')
- {
- wxPuts (_T("%hhn overwrite more bytes"));
- result = 1;
- }
- if (bytes[3] != 3)
- {
- wxPuts (_T("%hhn wrote incorrect value"));
- result = 1;
- }
- }
-#endif
-}
-
-static void
-rfg1 (void)
-{
- wxChar buf[100];
-
- wxSprintf (buf, _T("%5.s"), _T("xyz"));
- if (wxStrcmp (buf, _T(" ")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" "));
- wxSprintf (buf, _T("%5.f"), 33.3);
- if (wxStrcmp (buf, _T(" 33")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 33"));
- wxSprintf (buf, _T("%8.e"), 33.3e7);
- if (wxStrcmp (buf, _T(" 3e+08")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 3e+08"));
- wxSprintf (buf, _T("%8.E"), 33.3e7);
- if (wxStrcmp (buf, _T(" 3E+08")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 3E+08"));
- wxSprintf (buf, _T("%.g"), 33.3);
- if (wxStrcmp (buf, _T("3e+01")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T("3e+01"));
- wxSprintf (buf, _T("%.G"), 33.3);
- if (wxStrcmp (buf, _T("3E+01")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T("3E+01"));
-}
-
-static void
-rfg2 (void)
-{
- int prec;
- wxChar buf[100];
- wxString test_format;
-
- prec = 0;
- wxSprintf (buf, _T("%.*g"), prec, 3.3);
- if (wxStrcmp (buf, _T("3")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T("3"));
- prec = 0;
- wxSprintf (buf, _T("%.*G"), prec, 3.3);
- if (wxStrcmp (buf, _T("3")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T("3"));
- prec = 0;
- wxSprintf (buf, _T("%7.*G"), prec, 3.33);
- if (wxStrcmp (buf, _T(" 3")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 3"));
- prec = 3;
- test_format = _T("%04.*o");
- wxSprintf (buf, test_format.c_str(), prec, 33);
- if (wxStrcmp (buf, _T(" 041")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 041"));
- prec = 7;
- test_format = _T("%09.*u");
- wxSprintf (buf, test_format.c_str(), prec, 33);
- if (wxStrcmp (buf, _T(" 0000033")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 0000033"));
- prec = 3;
- test_format = _T("%04.*x");
- wxSprintf (buf, test_format.c_str(), prec, 33);
- if (wxStrcmp (buf, _T(" 021")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 021"));
- prec = 3;
- test_format = _T("%04.*X");
- wxSprintf (buf, test_format.c_str(), prec, 33);
- if (wxStrcmp (buf, _T(" 021")) != 0)
- wxPrintf (_T("got: '%s', expected: '%s'\n"), buf, _T(" 021"));
-}
-
-#endif // TEST_PRINTF
-
-// ----------------------------------------------------------------------------
-// registry and related stuff
-// ----------------------------------------------------------------------------
-
-// this is for MSW only
-#ifndef __WXMSW__
- #undef TEST_REGCONF
- #undef TEST_REGISTRY
-#endif
-
-#ifdef TEST_REGCONF
-
-#include "wx/confbase.h"
-#include "wx/msw/regconf.h"
-
-#if 0
-static void TestRegConfWrite()
-{
- wxConfig *config = new wxConfig(_T("myapp"));
- config->SetPath(_T("/group1"));
- config->Write(_T("entry1"), _T("foo"));
- config->SetPath(_T("/group2"));
- config->Write(_T("entry1"), _T("bar"));
-}
-#endif
-
-static void TestRegConfRead()
-{
- wxConfig *config = new wxConfig(_T("myapp"));
-
- wxString str;
- long dummy;
- config->SetPath(_T("/"));
- wxPuts(_T("Enumerating / subgroups:"));
- bool bCont = config->GetFirstGroup(str, dummy);
- while(bCont)
- {
- wxPuts(str);
- bCont = config->GetNextGroup(str, dummy);
- }
-}
-
-#endif // TEST_REGCONF
-
-#ifdef TEST_REGISTRY
-
-#include "wx/msw/registry.h"
-
-// I chose this one because I liked its name, but it probably only exists under
-// NT
-static const wxChar *TESTKEY =
- _T("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
-
-static void TestRegistryRead()
-{
- wxPuts(_T("*** testing registry reading ***"));
-
- wxRegKey key(TESTKEY);
- wxPrintf(_T("The test key name is '%s'.\n"), key.GetName().c_str());
- if ( !key.Open() )
- {
- wxPuts(_T("ERROR: test key can't be opened, aborting test."));
-
- return;
- }
-
- size_t nSubKeys, nValues;
- if ( key.GetKeyInfo(&nSubKeys, NULL, &nValues, NULL) )
- {
- wxPrintf(_T("It has %u subkeys and %u values.\n"), nSubKeys, nValues);
- }
-
- wxPrintf(_T("Enumerating values:\n"));
-
- long dummy;
- wxString value;
- bool cont = key.GetFirstValue(value, dummy);
- while ( cont )
- {
- wxPrintf(_T("Value '%s': type "), value.c_str());
- switch ( key.GetValueType(value) )
- {
- case wxRegKey::Type_None: wxPrintf(_T("ERROR (none)")); break;
- case wxRegKey::Type_String: wxPrintf(_T("SZ")); break;
- case wxRegKey::Type_Expand_String: wxPrintf(_T("EXPAND_SZ")); break;
- case wxRegKey::Type_Binary: wxPrintf(_T("BINARY")); break;
- case wxRegKey::Type_Dword: wxPrintf(_T("DWORD")); break;
- case wxRegKey::Type_Multi_String: wxPrintf(_T("MULTI_SZ")); break;
- default: wxPrintf(_T("other (unknown)")); break;
- }
-
- wxPrintf(_T(", value = "));
- if ( key.IsNumericValue(value) )
- {
- long val;
- key.QueryValue(value, &val);
- wxPrintf(_T("%ld"), val);
- }
- else // string
- {
- wxString val;
- key.QueryValue(value, val);
- wxPrintf(_T("'%s'"), val.c_str());
-
- key.QueryRawValue(value, val);
- wxPrintf(_T(" (raw value '%s')"), val.c_str());
- }
-
- wxPutchar('\n');
-
- cont = key.GetNextValue(value, dummy);
- }
-}
-
-static void TestRegistryAssociation()
-{
- /*
- The second call to deleteself genertaes an error message, with a
- messagebox saying .flo is crucial to system operation, while the .ddf
- call also fails, but with no error message
- */
-
- wxRegKey key;
-
- key.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
- key.Create();
- key = _T("ddxf_auto_file") ;
- key.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
- key.Create();
- key = _T("ddxf_auto_file") ;
- key.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
- key.Create();
- key = _T("program,0") ;
- key.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
- key.Create();
- key = _T("program \"%1\"") ;
-
- key.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
- key.DeleteSelf();
- key.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
- key.DeleteSelf();
- key.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
- key.DeleteSelf();
- key.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
- key.DeleteSelf();
-}
-
-#endif // TEST_REGISTRY
-
-// ----------------------------------------------------------------------------
-// scope guard
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_SCOPEGUARD
-
-#include "wx/scopeguard.h"
-
-static void function0() { puts("function0()"); }
-static void function1(int n) { printf("function1(%d)\n", n); }
-static void function2(double x, char c) { printf("function2(%g, %c)\n", x, c); }
-
-struct Object
-{
- void method0() { printf("method0()\n"); }
- void method1(int n) { printf("method1(%d)\n", n); }
- void method2(double x, char c) { printf("method2(%g, %c)\n", x, c); }
-};
-
-static void TestScopeGuard()
-{
- wxON_BLOCK_EXIT0(function0);
- wxON_BLOCK_EXIT1(function1, 17);
- wxON_BLOCK_EXIT2(function2, 3.14, 'p');
-
- Object obj;
- wxON_BLOCK_EXIT_OBJ0(obj, &Object::method0);
- wxON_BLOCK_EXIT_OBJ1(obj, &Object::method1, 7);
- wxON_BLOCK_EXIT_OBJ2(obj, &Object::method2, 2.71, 'e');
-
- wxScopeGuard dismissed = wxMakeGuard(function0);
- dismissed.Dismiss();
-}
-
-#endif
-
-// ----------------------------------------------------------------------------
-// sockets
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_SOCKETS
-
-#include "wx/socket.h"
-#include "wx/protocol/protocol.h"
-#include "wx/protocol/http.h"
-
-static void TestSocketServer()
-{
- wxPuts(_T("*** Testing wxSocketServer ***\n"));
-
- static const int PORT = 3000;
-
- wxIPV4address addr;
- addr.Service(PORT);
-
- wxSocketServer *server = new wxSocketServer(addr);
- if ( !server->Ok() )
- {
- wxPuts(_T("ERROR: failed to bind"));
-
- return;
- }
-
- bool quit = false;
- while ( !quit )
- {
- wxPrintf(_T("Server: waiting for connection on port %d...\n"), PORT);
-
- wxSocketBase *socket = server->Accept();
- if ( !socket )
- {
- wxPuts(_T("ERROR: wxSocketServer::Accept() failed."));
- break;
- }
-
- wxPuts(_T("Server: got a client."));
-
- server->SetTimeout(60); // 1 min
-
- bool close = false;
- while ( !close && socket->IsConnected() )
- {
- wxString s;
- wxChar ch = _T('\0');
- for ( ;; )
- {
- if ( socket->Read(&ch, sizeof(ch)).Error() )
- {
- // don't log error if the client just close the connection
- if ( socket->IsConnected() )
- {
- wxPuts(_T("ERROR: in wxSocket::Read."));
- }
-
- break;
- }
-
- if ( ch == '\r' )
- continue;
-
- if ( ch == '\n' )
- break;
-
- s += ch;
- }
-
- if ( ch != '\n' )
- {
- break;
- }
-
- wxPrintf(_T("Server: got '%s'.\n"), s.c_str());
- if ( s == _T("close") )
- {
- wxPuts(_T("Closing connection"));
-
- close = true;
- }
- else if ( s == _T("quit") )
- {
- close =
- quit = true;
-
- wxPuts(_T("Shutting down the server"));
- }
- else // not a special command
- {
- socket->Write(s.MakeUpper().c_str(), s.length());
- socket->Write("\r\n", 2);
- wxPrintf(_T("Server: wrote '%s'.\n"), s.c_str());
- }
- }
-
- if ( !close )
- {
- wxPuts(_T("Server: lost a client unexpectedly."));
- }
-
- socket->Destroy();
- }
-
- // same as "delete server" but is consistent with GUI programs
- server->Destroy();
-}
-
-static void TestSocketClient()
-{
- wxPuts(_T("*** Testing wxSocketClient ***\n"));
-
- static const wxChar *hostname = _T("www.wxwindows.org");
-
- wxIPV4address addr;
- addr.Hostname(hostname);
- addr.Service(80);
-
- wxPrintf(_T("--- Attempting to connect to %s:80...\n"), hostname);
-
- wxSocketClient client;
- if ( !client.Connect(addr) )
- {
- wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname);
- }
- else
- {
- wxPrintf(_T("--- Connected to %s:%u...\n"),
- addr.Hostname().c_str(), addr.Service());
-
- wxChar buf[8192];
-
- // could use simply "GET" here I suppose
- wxString cmdGet =
- wxString::Format(_T("GET http://%s/\r\n"), hostname);
- client.Write(cmdGet, cmdGet.length());
- wxPrintf(_T("--- Sent command '%s' to the server\n"),
- MakePrintable(cmdGet).c_str());
- client.Read(buf, WXSIZEOF(buf));
- wxPrintf(_T("--- Server replied:\n%s"), buf);
- }
-}
-
-#endif // TEST_SOCKETS
-
-// ----------------------------------------------------------------------------
-// FTP
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_FTP
-
-#include "wx/protocol/ftp.h"
-
-static wxFTP ftp;
-
-#define FTP_ANONYMOUS
-
-#ifdef FTP_ANONYMOUS
- static const wxChar *directory = _T("/pub");
- static const wxChar *filename = _T("welcome.msg");
-#else
- static const wxChar *directory = _T("/etc");
- static const wxChar *filename = _T("issue");
-#endif
-
-static bool TestFtpConnect()
-{
- wxPuts(_T("*** Testing FTP connect ***"));
-
-#ifdef FTP_ANONYMOUS
- static const wxChar *hostname = _T("ftp.wxwindows.org");
-
- wxPrintf(_T("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
-#else // !FTP_ANONYMOUS
- static const wxChar *hostname = "localhost";
-
- wxChar user[256];
- wxFgets(user, WXSIZEOF(user), stdin);
- user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
- ftp.SetUser(user);
-
- wxChar password[256];
- wxPrintf(_T("Password for %s: "), password);
- wxFgets(password, WXSIZEOF(password), stdin);
- password[wxStrlen(password) - 1] = '\0'; // chop off '\n'
- ftp.SetPassword(password);
-
- wxPrintf(_T("--- Attempting to connect to %s:21 as %s...\n"), hostname, user);
-#endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
-
- if ( !ftp.Connect(hostname) )
- {
- wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname);
-
- return false;
- }
- else
- {
- wxPrintf(_T("--- Connected to %s, current directory is '%s'\n"),
- hostname, ftp.Pwd().c_str());
- }
-
- return true;
-}
-
-// test (fixed?) wxFTP bug with wu-ftpd >= 2.6.0?
-static void TestFtpWuFtpd()
-{
- wxFTP ftp;
- static const wxChar *hostname = _T("ftp.eudora.com");
- if ( !ftp.Connect(hostname) )
- {
- wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname);
- }
- else
- {
- static const wxChar *filename = _T("eudora/pubs/draft-gellens-submit-09.txt");
- wxInputStream *in = ftp.GetInputStream(filename);
- if ( !in )
- {
- wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename);
- }
- else
- {
- size_t size = in->GetSize();
- wxPrintf(_T("Reading file %s (%u bytes)..."), filename, size);
-
- wxChar *data = new wxChar[size];
- if ( !in->Read(data, size) )
- {
- wxPuts(_T("ERROR: read error"));
- }
- else
- {
- wxPrintf(_T("Successfully retrieved the file.\n"));
- }
-
- delete [] data;
- delete in;
- }
- }
-}
-
-static void TestFtpList()
-{
- wxPuts(_T("*** Testing wxFTP file listing ***\n"));
-
- // test CWD
- if ( !ftp.ChDir(directory) )
- {
- wxPrintf(_T("ERROR: failed to cd to %s\n"), directory);
- }
-
- wxPrintf(_T("Current directory is '%s'\n"), ftp.Pwd().c_str());
-
- // test NLIST and LIST
- wxArrayString files;
- if ( !ftp.GetFilesList(files) )
- {
- wxPuts(_T("ERROR: failed to get NLIST of files"));
- }
- else
- {
- wxPrintf(_T("Brief list of files under '%s':\n"), ftp.Pwd().c_str());
- size_t count = files.GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- wxPrintf(_T("\t%s\n"), files[n].c_str());
- }
- wxPuts(_T("End of the file list"));
- }
-
- if ( !ftp.GetDirList(files) )
- {
- wxPuts(_T("ERROR: failed to get LIST of files"));
- }
- else
- {
- wxPrintf(_T("Detailed list of files under '%s':\n"), ftp.Pwd().c_str());
- size_t count = files.GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- wxPrintf(_T("\t%s\n"), files[n].c_str());
- }
- wxPuts(_T("End of the file list"));
- }
-
- if ( !ftp.ChDir(_T("..")) )
- {
- wxPuts(_T("ERROR: failed to cd to .."));
- }
-
- wxPrintf(_T("Current directory is '%s'\n"), ftp.Pwd().c_str());
-}
-
-static void TestFtpDownload()
-{
- wxPuts(_T("*** Testing wxFTP download ***\n"));
-
- // test RETR
- wxInputStream *in = ftp.GetInputStream(filename);
- if ( !in )
- {
- wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename);
- }
- else
- {
- size_t size = in->GetSize();
- wxPrintf(_T("Reading file %s (%u bytes)..."), filename, size);
- fflush(stdout);
-
- wxChar *data = new wxChar[size];
- if ( !in->Read(data, size) )
- {
- wxPuts(_T("ERROR: read error"));
- }
- else
- {
- wxPrintf(_T("\nContents of %s:\n%s\n"), filename, data);
- }
-
- delete [] data;
- delete in;
- }
-}
-
-static void TestFtpFileSize()
-{
- wxPuts(_T("*** Testing FTP SIZE command ***"));
-
- if ( !ftp.ChDir(directory) )
- {
- wxPrintf(_T("ERROR: failed to cd to %s\n"), directory);
- }
-
- wxPrintf(_T("Current directory is '%s'\n"), ftp.Pwd().c_str());
-
- if ( ftp.FileExists(filename) )
- {
- int size = ftp.GetFileSize(filename);
- if ( size == -1 )
- wxPrintf(_T("ERROR: couldn't get size of '%s'\n"), filename);
- else
- wxPrintf(_T("Size of '%s' is %d bytes.\n"), filename, size);
- }
- else
- {
- wxPrintf(_T("ERROR: '%s' doesn't exist\n"), filename);
- }
-}
-
-static void TestFtpMisc()
-{
- wxPuts(_T("*** Testing miscellaneous wxFTP functions ***"));
-
- if ( ftp.SendCommand(_T("STAT")) != '2' )
- {
- wxPuts(_T("ERROR: STAT failed"));
- }
- else
- {
- wxPrintf(_T("STAT returned:\n\n%s\n"), ftp.GetLastResult().c_str());
- }
-
- if ( ftp.SendCommand(_T("HELP SITE")) != '2' )
- {
- wxPuts(_T("ERROR: HELP SITE failed"));
- }
- else
- {
- wxPrintf(_T("The list of site-specific commands:\n\n%s\n"),
- ftp.GetLastResult().c_str());
- }
-}
-
-static void TestFtpInteractive()
-{
- wxPuts(_T("\n*** Interactive wxFTP test ***"));
-
- wxChar buf[128];
-
- for ( ;; )
- {
- wxPrintf(_T("Enter FTP command: "));
- if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
- break;
-
- // kill the last '\n'
- buf[wxStrlen(buf) - 1] = 0;
-
- // special handling of LIST and NLST as they require data connection
- wxString start(buf, 4);
- start.MakeUpper();
- if ( start == _T("LIST") || start == _T("NLST") )
- {
- wxString wildcard;
- if ( wxStrlen(buf) > 4 )
- wildcard = buf + 5;
-
- wxArrayString files;
- if ( !ftp.GetList(files, wildcard, start == _T("LIST")) )
- {
- wxPrintf(_T("ERROR: failed to get %s of files\n"), start.c_str());
- }
- else
- {
- wxPrintf(_T("--- %s of '%s' under '%s':\n"),
- start.c_str(), wildcard.c_str(), ftp.Pwd().c_str());
- size_t count = files.GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- wxPrintf(_T("\t%s\n"), files[n].c_str());
- }
- wxPuts(_T("--- End of the file list"));
- }
- }
- else // !list
- {
- wxChar ch = ftp.SendCommand(buf);
- wxPrintf(_T("Command %s"), ch ? _T("succeeded") : _T("failed"));
- if ( ch )
- {
- wxPrintf(_T(" (return code %c)"), ch);
- }
-
- wxPrintf(_T(", server reply:\n%s\n\n"), ftp.GetLastResult().c_str());
- }
- }
-
- wxPuts(_T("\n*** done ***"));
-}
-
-static void TestFtpUpload()
-{
- wxPuts(_T("*** Testing wxFTP uploading ***\n"));
-
- // upload a file
- static const wxChar *file1 = _T("test1");
- static const wxChar *file2 = _T("test2");
- wxOutputStream *out = ftp.GetOutputStream(file1);
- if ( out )
- {
- wxPrintf(_T("--- Uploading to %s ---\n"), file1);
- out->Write("First hello", 11);
- delete out;
- }
-
- // send a command to check the remote file
- if ( ftp.SendCommand(wxString(_T("STAT ")) + file1) != '2' )
- {
- wxPrintf(_T("ERROR: STAT %s failed\n"), file1);
- }
- else
- {
- wxPrintf(_T("STAT %s returned:\n\n%s\n"),
- file1, ftp.GetLastResult().c_str());
- }
-
- out = ftp.GetOutputStream(file2);
- if ( out )
- {
- wxPrintf(_T("--- Uploading to %s ---\n"), file1);
- out->Write("Second hello", 12);
- delete out;
- }
-}
-
-#endif // TEST_FTP
-
-// ----------------------------------------------------------------------------
-// streams
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_STREAMS
-
-#include "wx/wfstream.h"
-#include "wx/mstream.h"
-
-static void TestFileStream()
-{
- wxPuts(_T("*** Testing wxFileInputStream ***"));
-
- static const wxString filename = _T("testdata.fs");
- {
- wxFileOutputStream fsOut(filename);
- fsOut.Write("foo", 3);
- }
-
- wxFileInputStream fsIn(filename);
- wxPrintf(_T("File stream size: %u\n"), fsIn.GetSize());
- while ( !fsIn.Eof() )
- {
- wxPutchar(fsIn.GetC());
- }
-
- if ( !wxRemoveFile(filename) )
- {
- wxPrintf(_T("ERROR: failed to remove the file '%s'.\n"), filename.c_str());
- }
-
- wxPuts(_T("\n*** wxFileInputStream test done ***"));
-}
-
-static void TestMemoryStream()
-{
- wxPuts(_T("*** Testing wxMemoryOutputStream ***"));
-
- wxMemoryOutputStream memOutStream;
- wxPrintf(_T("Initially out stream offset: %lu\n"),
- (unsigned long)memOutStream.TellO());
-
- for ( const wxChar *p = _T("Hello, stream!"); *p; p++ )
- {
- memOutStream.PutC(*p);
- }
-
- wxPrintf(_T("Final out stream offset: %lu\n"),
- (unsigned long)memOutStream.TellO());
-
- wxPuts(_T("*** Testing wxMemoryInputStream ***"));
-
- wxChar buf[1024];
- size_t len = memOutStream.CopyTo(buf, WXSIZEOF(buf));
-
- wxMemoryInputStream memInpStream(buf, len);
- wxPrintf(_T("Memory stream size: %u\n"), memInpStream.GetSize());
- while ( !memInpStream.Eof() )
- {
- wxPutchar(memInpStream.GetC());
- }
-
- wxPuts(_T("\n*** wxMemoryInputStream test done ***"));
-}
-
-#endif // TEST_STREAMS
-
-// ----------------------------------------------------------------------------
-// timers
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_TIMER
-
-#include "wx/timer.h"
-#include "wx/utils.h"
-
-static void TestStopWatch()
-{
- wxPuts(_T("*** Testing wxStopWatch ***\n"));
-
- wxStopWatch sw;
- sw.Pause();
- wxPrintf(_T("Initially paused, after 2 seconds time is..."));
- fflush(stdout);
- wxSleep(2);
- wxPrintf(_T("\t%ldms\n"), sw.Time());
-
- wxPrintf(_T("Resuming stopwatch and sleeping 3 seconds..."));
- fflush(stdout);
- sw.Resume();
- wxSleep(3);
- wxPrintf(_T("\telapsed time: %ldms\n"), sw.Time());
-
- sw.Pause();
- wxPrintf(_T("Pausing agan and sleeping 2 more seconds..."));
- fflush(stdout);
- wxSleep(2);
- wxPrintf(_T("\telapsed time: %ldms\n"), sw.Time());
-
- sw.Resume();
- wxPrintf(_T("Finally resuming and sleeping 2 more seconds..."));
- fflush(stdout);
- wxSleep(2);
- wxPrintf(_T("\telapsed time: %ldms\n"), sw.Time());
-
- wxStopWatch sw2;
- wxPuts(_T("\nChecking for 'backwards clock' bug..."));
- for ( size_t n = 0; n < 70; n++ )
- {
- sw2.Start();
-
- for ( size_t m = 0; m < 100000; m++ )
- {
- if ( sw.Time() < 0 || sw2.Time() < 0 )
- {
- wxPuts(_T("\ntime is negative - ERROR!"));
- }
- }
-
- wxPutchar('.');
- fflush(stdout);
- }
-
- wxPuts(_T(", ok."));
-}
-
-#endif // TEST_TIMER
-
-// ----------------------------------------------------------------------------
-// vCard support
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_VCARD
-
-#include "wx/vcard.h"
-
-static void DumpVObject(size_t level, const wxVCardObject& vcard)
-{
- void *cookie;
- wxVCardObject *vcObj = vcard.GetFirstProp(&cookie);
- while ( vcObj )
- {
- wxPrintf(_T("%s%s"),
- wxString(_T('\t'), level).c_str(),
- vcObj->GetName().c_str());
-
- wxString value;
- switch ( vcObj->GetType() )
- {
- case wxVCardObject::String:
- case wxVCardObject::UString:
- {
- wxString val;
- vcObj->GetValue(&val);
- value << _T('"') << val << _T('"');
- }
- break;
-
- case wxVCardObject::Int:
- {
- unsigned int i;
- vcObj->GetValue(&i);
- value.Printf(_T("%u"), i);
- }
- break;
-
- case wxVCardObject::Long:
- {
- unsigned long l;
- vcObj->GetValue(&l);
- value.Printf(_T("%lu"), l);
- }
- break;
-
- case wxVCardObject::None:
- break;
-
- case wxVCardObject::Object:
- value = _T("<node>");
- break;
-
- default:
- value = _T("<unknown value type>");
- }
-
- if ( !!value )
- wxPrintf(_T(" = %s"), value.c_str());
- wxPutchar('\n');
-
- DumpVObject(level + 1, *vcObj);
-
- delete vcObj;
- vcObj = vcard.GetNextProp(&cookie);
- }
-}
-
-static void DumpVCardAddresses(const wxVCard& vcard)
-{
- wxPuts(_T("\nShowing all addresses from vCard:\n"));
-
- size_t nAdr = 0;
- void *cookie;
- wxVCardAddress *addr = vcard.GetFirstAddress(&cookie);
- while ( addr )
- {
- wxString flagsStr;
- int flags = addr->GetFlags();
- if ( flags & wxVCardAddress::Domestic )
- {
- flagsStr << _T("domestic ");
- }
- if ( flags & wxVCardAddress::Intl )
- {
- flagsStr << _T("international ");
- }
- if ( flags & wxVCardAddress::Postal )
- {
- flagsStr << _T("postal ");
- }
- if ( flags & wxVCardAddress::Parcel )
- {
- flagsStr << _T("parcel ");
- }
- if ( flags & wxVCardAddress::Home )
- {
- flagsStr << _T("home ");
- }
- if ( flags & wxVCardAddress::Work )
- {
- flagsStr << _T("work ");
- }
-
- wxPrintf(_T("Address %u:\n")
- "\tflags = %s\n"
- "\tvalue = %s;%s;%s;%s;%s;%s;%s\n",
- ++nAdr,
- flagsStr.c_str(),
- addr->GetPostOffice().c_str(),
- addr->GetExtAddress().c_str(),
- addr->GetStreet().c_str(),
- addr->GetLocality().c_str(),
- addr->GetRegion().c_str(),
- addr->GetPostalCode().c_str(),
- addr->GetCountry().c_str()
- );
-
- delete addr;
- addr = vcard.GetNextAddress(&cookie);
- }
-}
-
-static void DumpVCardPhoneNumbers(const wxVCard& vcard)
-{
- wxPuts(_T("\nShowing all phone numbers from vCard:\n"));
-
- size_t nPhone = 0;
- void *cookie;
- wxVCardPhoneNumber *phone = vcard.GetFirstPhoneNumber(&cookie);
- while ( phone )
- {
- wxString flagsStr;
- int flags = phone->GetFlags();
- if ( flags & wxVCardPhoneNumber::Voice )
- {
- flagsStr << _T("voice ");
- }
- if ( flags & wxVCardPhoneNumber::Fax )
- {
- flagsStr << _T("fax ");
- }
- if ( flags & wxVCardPhoneNumber::Cellular )
- {
- flagsStr << _T("cellular ");
- }
- if ( flags & wxVCardPhoneNumber::Modem )
- {
- flagsStr << _T("modem ");
- }
- if ( flags & wxVCardPhoneNumber::Home )
- {
- flagsStr << _T("home ");
- }
- if ( flags & wxVCardPhoneNumber::Work )
- {
- flagsStr << _T("work ");
- }
-
- wxPrintf(_T("Phone number %u:\n")
- "\tflags = %s\n"
- "\tvalue = %s\n",
- ++nPhone,
- flagsStr.c_str(),
- phone->GetNumber().c_str()
- );
-
- delete phone;
- phone = vcard.GetNextPhoneNumber(&cookie);
- }
-}
-
-static void TestVCardRead()
-{
- wxPuts(_T("*** Testing wxVCard reading ***\n"));
-
- wxVCard vcard(_T("vcard.vcf"));
- if ( !vcard.IsOk() )
- {
- wxPuts(_T("ERROR: couldn't load vCard."));
- }
- else
- {
- // read individual vCard properties
- wxVCardObject *vcObj = vcard.GetProperty("FN");
- wxString value;
- if ( vcObj )
- {
- vcObj->GetValue(&value);
- delete vcObj;
- }
- else
- {
- value = _T("<none>");
- }
-
- wxPrintf(_T("Full name retrieved directly: %s\n"), value.c_str());
-
-
- if ( !vcard.GetFullName(&value) )
- {
- value = _T("<none>");
- }
-
- wxPrintf(_T("Full name from wxVCard API: %s\n"), value.c_str());
-
- // now show how to deal with multiply occuring properties
- DumpVCardAddresses(vcard);
- DumpVCardPhoneNumbers(vcard);
-
- // and finally show all
- wxPuts(_T("\nNow dumping the entire vCard:\n")
- "-----------------------------\n");
-
- DumpVObject(0, vcard);
- }
-}
-
-static void TestVCardWrite()
-{
- wxPuts(_T("*** Testing wxVCard writing ***\n"));
-
- wxVCard vcard;
- if ( !vcard.IsOk() )
- {
- wxPuts(_T("ERROR: couldn't create vCard."));
- }
- else
- {
- // set some fields
- vcard.SetName("Zeitlin", "Vadim");
- vcard.SetFullName("Vadim Zeitlin");
- vcard.SetOrganization("wxWindows", "R&D");
-
- // just dump the vCard back
- wxPuts(_T("Entire vCard follows:\n"));
- wxPuts(vcard.Write());
- }
-}
-
-#endif // TEST_VCARD
-
-// ----------------------------------------------------------------------------
-// wxVolume tests
-// ----------------------------------------------------------------------------
-
-#if !defined(__WIN32__) || !wxUSE_FSVOLUME
- #undef TEST_VOLUME
-#endif
-
-#ifdef TEST_VOLUME
-
-#include "wx/volume.h"
-
-static const wxChar *volumeKinds[] =
-{
- _T("floppy"),
- _T("hard disk"),
- _T("CD-ROM"),
- _T("DVD-ROM"),
- _T("network volume"),
- _T("other volume"),
-};
-
-static void TestFSVolume()
-{
- wxPuts(_T("*** Testing wxFSVolume class ***"));
-
- wxArrayString volumes = wxFSVolume::GetVolumes();
- size_t count = volumes.GetCount();
-
- if ( !count )
- {
- wxPuts(_T("ERROR: no mounted volumes?"));
- return;
- }
-
- wxPrintf(_T("%u mounted volumes found:\n"), count);
-
- for ( size_t n = 0; n < count; n++ )
- {
- wxFSVolume vol(volumes[n]);
- if ( !vol.IsOk() )
- {
- wxPuts(_T("ERROR: couldn't create volume"));
- continue;
- }
-
- wxPrintf(_T("%u: %s (%s), %s, %s, %s\n"),
- n + 1,
- vol.GetDisplayName().c_str(),
- vol.GetName().c_str(),
- volumeKinds[vol.GetKind()],
- vol.IsWritable() ? _T("rw") : _T("ro"),
- vol.GetFlags() & wxFS_VOL_REMOVABLE ? _T("removable")
- : _T("fixed"));
- }
-}
-
-#endif // TEST_VOLUME
-
-// ----------------------------------------------------------------------------
-// wide char and Unicode support
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_UNICODE
-
-static void TestUnicodeToFromAscii()
-{
- wxPuts(_T("Testing wxString::To/FromAscii()\n"));
-
- static const char *msg = "Hello, world!";
- wxString s = wxString::FromAscii(msg);
-
- wxPrintf(_T("Message in Unicode: %s\n"), s.c_str());
- printf("Message in ASCII: %s\n", (const char *)s.ToAscii());
-
- 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
-
-#ifdef TEST_WCHAR
-
-#include "wx/strconv.h"
-#include "wx/fontenc.h"
-#include "wx/encconv.h"
-#include "wx/buffer.h"
-
-static const unsigned char utf8koi8r[] =
-{
- 208, 157, 208, 181, 209, 129, 208, 186, 208, 176, 208, 183, 208, 176,
- 208, 189, 208, 189, 208, 190, 32, 208, 191, 208, 190, 209, 128, 208,
- 176, 208, 180, 208, 190, 208, 178, 208, 176, 208, 187, 32, 208, 188,
- 208, 181, 208, 189, 209, 143, 32, 209, 129, 208, 178, 208, 190, 208,
- 181, 208, 185, 32, 208, 186, 209, 128, 209, 131, 209, 130, 208, 181,
- 208, 185, 209, 136, 208, 181, 208, 185, 32, 208, 189, 208, 190, 208,
- 178, 208, 190, 209, 129, 209, 130, 209, 140, 209, 142, 0
-};
-
-static const unsigned char utf8iso8859_1[] =
-{
- 0x53, 0x79, 0x73, 0x74, 0xc3, 0xa8, 0x6d, 0x65, 0x73, 0x20, 0x49, 0x6e,
- 0x74, 0xc3, 0xa9, 0x67, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x65,
- 0x6e, 0x20, 0x4d, 0xc3, 0xa9, 0x63, 0x61, 0x6e, 0x69, 0x71, 0x75, 0x65,
- 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65,
- 0x74, 0x20, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x71, 0x75, 0x65, 0
-};
-
-static const unsigned char utf8Invalid[] =
-{
- 0x3c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3e, 0x32, 0x30, 0x30,
- 0x32, 0xe5, 0xb9, 0xb4, 0x30, 0x39, 0xe6, 0x9c, 0x88, 0x32, 0x35, 0xe6,
- 0x97, 0xa5, 0x20, 0x30, 0x37, 0xe6, 0x99, 0x82, 0x33, 0x39, 0xe5, 0x88,
- 0x86, 0x35, 0x37, 0xe7, 0xa7, 0x92, 0x3c, 0x2f, 0x64, 0x69, 0x73, 0x70,
- 0x6c, 0x61, 0x79, 0
-};
-
-static const struct Utf8Data
-{
- const unsigned char *text;
- size_t len;
- const wxChar *charset;
- wxFontEncoding encoding;
-} utf8data[] =
-{
- { utf8Invalid, WXSIZEOF(utf8Invalid), _T("iso8859-1"), wxFONTENCODING_ISO8859_1 },
- { utf8koi8r, WXSIZEOF(utf8koi8r), _T("koi8-r"), wxFONTENCODING_KOI8 },
- { utf8iso8859_1, WXSIZEOF(utf8iso8859_1), _T("iso8859-1"), wxFONTENCODING_ISO8859_1 },
-};