#include "wx/string.h"
#include "wx/file.h"
#include "wx/app.h"
+#include "wx/log.h"
// without this pragma, the stupid compiler precompiles #defines below so that
// changing them doesn't "take place" later!
*/
// what to test (in alphabetic order)? uncomment the line below to do all tests
-#define TEST_ALL
+//#define TEST_ALL
#ifdef TEST_ALL
#define TEST_ARRAYS
#define TEST_CHARSET
#define TEST_SOCKETS
#define TEST_STREAMS
#define TEST_STRINGS
+ #define TEST_TEXTSTREAM
#define TEST_THREADS
#define TEST_TIMER
#define TEST_UNICODE
#define TEST_ZLIB
#undef TEST_ALL
- static const bool TEST_ALL = TRUE;
+ static const bool TEST_ALL = true;
#else
- #define TEST_PRINTF
+ #define TEST_FILECONF
- static const bool TEST_ALL = FALSE;
+ static const bool TEST_ALL = false;
#endif
// some tests are interactive, define this to run them
#ifdef TEST_INTERACTIVE
#undef TEST_INTERACTIVE
- static const bool TEST_INTERACTIVE = TRUE;
+ static const bool TEST_INTERACTIVE = true;
#else
- static const bool TEST_INTERACTIVE = FALSE;
+ static const bool TEST_INTERACTIVE = false;
#endif
// ----------------------------------------------------------------------------
#include "wx/cmdline.h"
#include "wx/datetime.h"
-#include "wx/log.h"
#if wxUSE_CMDLINE_PARSER
#ifdef __UNIX__
static const wxChar *ROOTDIR = _T("/");
- static const wxChar *TESTDIR = _T("/usr");
+ static const wxChar *TESTDIR = _T("/usr/local/share");
#elif defined(__WXMSW__)
static const wxChar *ROOTDIR = _T("c:\\");
static const wxChar *TESTDIR = _T("d:\\");
}
// enum again with custom traverser
+ wxPuts(_T("Now enumerating directories:"));
wxDir dir(TESTDIR);
DirPrintTraverser traverser;
dir.Traverse(traverser, _T(""), wxDIR_DIRS | wxDIR_HIDDEN);
wxPrintf(_T("Testing wxExecute: "));
fflush(stdout);
- if ( wxExecute(COMMAND, TRUE /* sync */) == 0 )
+ if ( wxExecute(COMMAND, true /* sync */) == 0 )
wxPuts(_T("Ok."));
else
wxPuts(_T("ERROR."));
cont = fileconf.GetNextEntry(name, dummy);
}
+
+ static const wxChar *testEntry = _T("TestEntry");
+ wxPrintf(_T("\nTesting deletion of newly created \"Test\" entry: "));
+ fileconf.Write(testEntry, _T("A value"));
+ fileconf.DeleteEntry(testEntry);
+ wxPrintf(fileconf.HasEntry(testEntry) ? _T("ERROR\n") : _T("ok\n"));
}
#endif // TEST_FILECONF
} filenames[] =
{
// Unix file names
- { _T("/usr/bin/ls"), _T(""), _T("/usr/bin"), _T("ls"), _T(""), TRUE, wxPATH_UNIX },
- { _T("/usr/bin/"), _T(""), _T("/usr/bin"), _T(""), _T(""), TRUE, wxPATH_UNIX },
- { _T("~/.zshrc"), _T(""), _T("~"), _T(".zshrc"), _T(""), TRUE, wxPATH_UNIX },
- { _T("../../foo"), _T(""), _T("../.."), _T("foo"), _T(""), FALSE, wxPATH_UNIX },
- { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), FALSE, wxPATH_UNIX },
- { _T("~/foo.bar"), _T(""), _T("~"), _T("foo"), _T("bar"), TRUE, wxPATH_UNIX },
- { _T("/foo"), _T(""), _T("/"), _T("foo"), _T(""), TRUE, wxPATH_UNIX },
- { _T("Mahogany-0.60/foo.bar"), _T(""), _T("Mahogany-0.60"), _T("foo"), _T("bar"), FALSE, wxPATH_UNIX },
- { _T("/tmp/wxwin.tar.bz"), _T(""), _T("/tmp"), _T("wxwin.tar"), _T("bz"), TRUE, wxPATH_UNIX },
+ { _T("/usr/bin/ls"), _T(""), _T("/usr/bin"), _T("ls"), _T(""), true, wxPATH_UNIX },
+ { _T("/usr/bin/"), _T(""), _T("/usr/bin"), _T(""), _T(""), true, wxPATH_UNIX },
+ { _T("~/.zshrc"), _T(""), _T("~"), _T(".zshrc"), _T(""), true, wxPATH_UNIX },
+ { _T("../../foo"), _T(""), _T("../.."), _T("foo"), _T(""), false, wxPATH_UNIX },
+ { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), false, wxPATH_UNIX },
+ { _T("~/foo.bar"), _T(""), _T("~"), _T("foo"), _T("bar"), true, wxPATH_UNIX },
+ { _T("/foo"), _T(""), _T("/"), _T("foo"), _T(""), true, wxPATH_UNIX },
+ { _T("Mahogany-0.60/foo.bar"), _T(""), _T("Mahogany-0.60"), _T("foo"), _T("bar"), false, wxPATH_UNIX },
+ { _T("/tmp/wxwin.tar.bz"), _T(""), _T("/tmp"), _T("wxwin.tar"), _T("bz"), true, wxPATH_UNIX },
// Windows file names
- { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), FALSE, wxPATH_DOS },
- { _T("\\foo.bar"), _T(""), _T("\\"), _T("foo"), _T("bar"), FALSE, wxPATH_DOS },
- { _T("c:foo.bar"), _T("c"), _T(""), _T("foo"), _T("bar"), FALSE, wxPATH_DOS },
- { _T("c:\\foo.bar"), _T("c"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
- { _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), TRUE, wxPATH_DOS },
- { _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
- { _T("\\\\server\\dir\\foo.bar"), _T("server"), _T("\\dir"), _T("foo"), _T("bar"), TRUE, wxPATH_DOS },
+ { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), false, wxPATH_DOS },
+ { _T("\\foo.bar"), _T(""), _T("\\"), _T("foo"), _T("bar"), false, wxPATH_DOS },
+ { _T("c:foo.bar"), _T("c"), _T(""), _T("foo"), _T("bar"), false, wxPATH_DOS },
+ { _T("c:\\foo.bar"), _T("c"), _T("\\"), _T("foo"), _T("bar"), true, wxPATH_DOS },
+ { _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), true, wxPATH_DOS },
+ { _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), true, wxPATH_DOS },
+ { _T("\\\\server\\dir\\foo.bar"), _T("server"), _T("\\dir"), _T("foo"), _T("bar"), true, wxPATH_DOS },
// wxFileName support for Mac file names is broken currently
#if 0
// Mac file names
- { _T("Volume:Dir:File"), _T("Volume"), _T("Dir"), _T("File"), _T(""), TRUE, wxPATH_MAC },
- { _T("Volume:Dir:Subdir:File"), _T("Volume"), _T("Dir:Subdir"), _T("File"), _T(""), TRUE, wxPATH_MAC },
- { _T("Volume:"), _T("Volume"), _T(""), _T(""), _T(""), TRUE, wxPATH_MAC },
- { _T(":Dir:File"), _T(""), _T("Dir"), _T("File"), _T(""), FALSE, wxPATH_MAC },
- { _T(":File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), FALSE, wxPATH_MAC },
- { _T("File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), FALSE, wxPATH_MAC },
+ { _T("Volume:Dir:File"), _T("Volume"), _T("Dir"), _T("File"), _T(""), true, wxPATH_MAC },
+ { _T("Volume:Dir:Subdir:File"), _T("Volume"), _T("Dir:Subdir"), _T("File"), _T(""), true, wxPATH_MAC },
+ { _T("Volume:"), _T("Volume"), _T(""), _T(""), _T(""), true, wxPATH_MAC },
+ { _T(":Dir:File"), _T(""), _T("Dir"), _T("File"), _T(""), false, wxPATH_MAC },
+ { _T(":File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), false, wxPATH_MAC },
+ { _T("File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), false, wxPATH_MAC },
#endif // 0
// VMS file names
- { _T("device:[dir1.dir2.dir3]file.txt"), _T("device"), _T("dir1.dir2.dir3"), _T("file"), _T("txt"), TRUE, wxPATH_VMS },
- { _T("file.txt"), _T(""), _T(""), _T("file"), _T("txt"), FALSE, wxPATH_VMS },
+ { _T("device:[dir1.dir2.dir3]file.txt"), _T("device"), _T("dir1.dir2.dir3"), _T("file"), _T("txt"), true, wxPATH_VMS },
+ { _T("file.txt"), _T(""), _T(""), _T("file"), _T("txt"), false, wxPATH_VMS },
};
static void TestFileNameConstruction()
}
}
+static void TestFileNameMakeAbsolute()
+{
+ wxPuts(_T("*** testing wxFileName::MakeAbsolute() ***"));
+
+ for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
+ {
+ const FileNameInfo& fni = filenames[n];
+ wxFileName fn(fni.fullname, fni.format);
+
+ wxPrintf(_T("'%s' absolutized: "),
+ fn.GetFullPath(fni.format).c_str());
+ fn.MakeAbsolute();
+ wxPrintf(_T("'%s'\n"), fn.GetFullPath(fni.format).c_str());
+ }
+
+ wxPuts(_T(""));
+}
+
static void TestFileNameComparison()
{
// TODO!
{
wxHashFoos hash;
- hash.DeleteContents(TRUE);
+ hash.DeleteContents(true);
wxPrintf(_T("Hash created: %u foos in hash, %u foos totally\n"),
hash.GetCount(), Foo::count);
wxPrintf(_T("After 2nd list creation: %u and %u objects in the lists, %u objects total.\n"),
list1.GetCount(), list2.GetCount(), Bar::GetNumber());
- list1.DeleteContents(TRUE);
+ list1.DeleteContents(true);
}
wxPrintf(_T("After list destruction: %u objects left.\n"), Bar::GetNumber());
wxFileType::MessageParameters(fname, _T(""))) )
cmd = _T("<no command available>");
else
- cmd = wxString('"') + cmd + '"';
+ cmd = wxString(_T('"')) + cmd + _T('"');
wxPrintf(_T("To open %s (%s) do %s.\n"),
fname.c_str(), desc.c_str(), cmd.c_str());
#endif // wxUSE_LONGLONG_WX
}
-static void TestLongLongPrint()
+static void TestLongLongToString()
{
- wxPuts(_T("*** Testing wxLongLong printing ***\n"));
+ wxPuts(_T("*** Testing wxLongLong::ToString() ***\n"));
for ( size_t n = 0; n < WXSIZEOF(testLongs); n++ )
{
#ifdef wxLongLongFmtSpec
wxLongLong ll = wxLL(0x1234567890abcdef);
- wxString s = wxString::Format(_T("%") wxLongLongFmtSpec _T("x"),
- ll.GetValue());
+ wxString s = wxString::Format(_T("%") wxLongLongFmtSpec _T("x"), ll);
wxPrintf(_T("0x1234567890abcdef -> %s (%s)\n"),
s.c_str(), s == _T("1234567890abcdef") ? _T("ok") : _T("ERROR"));
#else // !wxLongLongFmtSpec
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 },
+ { _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;
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 },
+ { _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++ )
{
wxChar buf[200];
- wxSprintf (buf, _T("%07Lo"), (wxLongLong_t)040000000000);
+ wxSprintf(buf, _T("%07") wxLongLongFmtSpec _T("o"), wxLL(040000000000));
wxPrintf (_T("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf);
if (wxStrcmp (buf, _T("40000000000")) != 0)
return;
}
- for ( ;; )
+ bool quit = false;
+ while ( !quit )
{
wxPrintf(_T("Server: waiting for connection on port %d...\n"), PORT);
server->SetTimeout(60); // 1 min
- while ( socket->IsConnected() )
+ bool close = false;
+ while ( !close && socket->IsConnected() )
{
wxString s;
wxChar ch = _T('\0');
}
wxPrintf(_T("Server: got '%s'.\n"), s.c_str());
- if ( s == _T("bye") )
+ if ( s == _T("close") )
{
- delete socket;
+ wxPuts(_T("Closing connection"));
- break;
+ close = true;
}
+ else if ( s == _T("quit") )
+ {
+ close =
+ quit = true;
- socket->Write(s.MakeUpper().c_str(), s.length());
- socket->Write("\r\n", 2);
- wxPrintf(_T("Server: wrote '%s'.\n"), s.c_str());
+ 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());
+ }
}
- wxPuts(_T("Server: lost a client."));
+ if ( !close )
+ {
+ wxPuts(_T("Server: lost a client unexpectedly."));
+ }
socket->Destroy();
}
{
wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname);
- return FALSE;
+ return false;
}
else
{
hostname, ftp.Pwd().c_str());
}
- return TRUE;
+ return true;
}
// test (fixed?) wxFTP bug with wu-ftpd >= 2.6.0?
#include "wx/encconv.h"
#include "wx/buffer.h"
-static const unsigned char textInUtf8_[] =
+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,
178, 208, 190, 209, 129, 209, 130, 209, 140, 209, 142, 0
};
-#define textInUtf8 ((const char *)textInUtf8_)
+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 },
+};
static void TestUtf8()
{
char buf[1024];
wchar_t wbuf[1024];
- if ( wxConvUTF8.MB2WC(wbuf, textInUtf8, WXSIZEOF(textInUtf8)) <= 0 )
- {
- wxPuts(_T("ERROR: UTF-8 decoding failed."));
- }
- else
+
+ for ( size_t n = 0; n < WXSIZEOF(utf8data); n++ )
{
- wxCSConv conv(_T("koi8-r"));
- if ( conv.WC2MB(buf, wbuf, 0 /* not needed wcslen(wbuf) */) <= 0 )
+ const Utf8Data& u8d = utf8data[n];
+ if ( wxConvUTF8.MB2WC(wbuf, (const char *)u8d.text,
+ WXSIZEOF(wbuf)) == (size_t)-1 )
{
- wxPuts(_T("ERROR: conversion to KOI8-R failed."));
+ wxPuts(_T("ERROR: UTF-8 decoding failed."));
}
else
{
- wxPrintf(_T("The resulting string (in KOI8-R): %s\n"), buf);
+ wxCSConv conv(u8d.charset);
+ if ( conv.WC2MB(buf, wbuf, WXSIZEOF(buf)) == (size_t)-1 )
+ {
+ wxPrintf(_T("ERROR: conversion to %s failed.\n"), u8d.charset);
+ }
+ else
+ {
+ wxPrintf(_T("String in %s: %s\n"), u8d.charset, buf);
+ }
}
- }
- if ( wxConvUTF8.WC2MB(buf, L"à la", WXSIZEOF(buf)) <= 0 )
- {
- wxPuts(_T("ERROR: conversion to UTF-8 failed."));
- }
- else
- {
- wxPrintf(_T("The string in UTF-8: %s\n"), buf);
+ wxString s(wxConvUTF8.cMB2WC((const char *)u8d.text), *wxConvCurrent);
+ if ( s.empty() )
+ s = _T("<< conversion failed >>");
+ wxPrintf(_T("String in current cset: %s\n"), s.c_str());
+
}
wxPuts(_T(""));
// using wxEncodingConverter should give the same result as above
char buf[1024];
wchar_t wbuf[1024];
- if ( wxConvUTF8.MB2WC(wbuf, textInUtf8, WXSIZEOF(textInUtf8)) <= 0 )
+ if ( wxConvUTF8.MB2WC(wbuf, (const char *)utf8koi8r,
+ WXSIZEOF(utf8koi8r)) == (size_t)-1 )
{
wxPuts(_T("ERROR: UTF-8 decoding failed."));
}
wxEncodingConverter ec;
ec.Init(wxFONTENCODING_UNICODE, wxFONTENCODING_KOI8);
ec.Convert(wbuf, buf);
- wxPrintf(_T("The same string obtained using wxEC: %s\n"), buf);
+ wxPrintf(_T("The same KOI8-R string using wxEC: %s\n"), buf);
}
wxPuts(_T(""));
#include <math.h>
-#include "wx/date.h"
#include "wx/datetime.h"
// the test data
// first line: the years to test
{ 1990, 1976, 2000, 2030, 1984, },
- // second line: TRUE if leap, FALSE otherwise
- { FALSE, TRUE, TRUE, FALSE, TRUE }
+ // second line: true if leap, false otherwise
+ { false, true, true, false, true }
};
for ( size_t n = 0; n < nYears; n++ )
wxPrintf(_T(" (ERROR: should be %d)"), wn.dnum);
}
- wxPrintf(_T(", week in month is %d"), wmon);
- if ( wmon == wn.wmon )
- {
- wxPrintf(_T(" (ok)"));
- }
- else
+ wxPrintf(_T(", week in month = %d"), wmon);
+ if ( wmon != wn.wmon )
{
wxPrintf(_T(" (ERROR: should be %d)"), wn.wmon);
}
wxPrintf(_T(" (ERROR: should be %d)"), wn.wmon2);
}
- wxPrintf(_T(", week in year is %d"), week);
- if ( week == wn.week )
+ wxPrintf(_T(", week in year = %d"), week);
+ if ( week != wn.week )
{
- wxPuts(_T(" (ok)"));
+ wxPrintf(_T(" (ERROR: should be %d)"), wn.week);
}
- else
+
+ wxPutchar(_T('\n'));
+
+ wxDateTime dt2(1, wxDateTime::Jan, d.year);
+ dt2.SetToTheWeek(wn.week, dt.GetWeekDay());
+ if ( dt2 != dt )
{
- wxPrintf(_T(" (ERROR: should be %d)\n"), wn.week);
+ Date d2;
+ d2.Init(dt2.GetTm());
+ wxPrintf(_T("ERROR: SetToTheWeek() returned %s\n"),
+ d2.FormatDate().c_str());
}
}
}
}
else
{
- bool equal = FALSE; // suppress compilaer warning
+ bool equal = false; // suppress compilaer warning
switch ( kind )
{
case CompareBoth:
static const ParseTestData parseTestDates[] =
{
- { _T("Sat, 18 Dec 1999 00:46:40 +0100"), { 18, wxDateTime::Dec, 1999, 00, 46, 40 }, TRUE },
- { _T("Wed, 1 Dec 1999 05:17:20 +0300"), { 1, wxDateTime::Dec, 1999, 03, 17, 20 }, TRUE },
+ { _T("Sat, 18 Dec 1999 00:46:40 +0100"), { 18, wxDateTime::Dec, 1999, 00, 46, 40 }, true },
+ { _T("Wed, 1 Dec 1999 05:17:20 +0300"), { 1, wxDateTime::Dec, 1999, 03, 17, 20 }, true },
};
for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
wxPuts(_T(""));
}
-#if 0
+#endif // TEST_DATETIME
-// test compatibility with the old wxDate/wxTime classes
-static void TestTimeCompatibility()
-{
- wxPuts(_T("\n*** wxDateTime compatibility test ***"));
+// ----------------------------------------------------------------------------
+// wxTextInput/OutputStream
+// ----------------------------------------------------------------------------
- wxPrintf(_T("wxDate for JDN 0: %s\n"), wxDate(0l).FormatDate().c_str());
- wxPrintf(_T("wxDate for MJD 0: %s\n"), wxDate(2400000).FormatDate().c_str());
+#ifdef TEST_TEXTSTREAM
- double jdnNow = wxDateTime::Now().GetJDN();
- long jdnMidnight = (long)(jdnNow - 0.5);
- wxPrintf(_T("wxDate for today: %s\n"), wxDate(jdnMidnight).FormatDate().c_str());
+#include "wx/txtstrm.h"
+#include "wx/wfstream.h"
- jdnMidnight = wxDate().Set().GetJulianDate();
- wxPrintf(_T("wxDateTime for today: %s\n"),
- wxDateTime((double)(jdnMidnight + 0.5)).Format("%c", wxDateTime::GMT0).c_str());
+static void TestTextInputStream()
+{
+ wxPuts(_T("\n*** wxTextInputStream test ***"));
- int flags = wxEUROPEAN;//wxFULL;
- wxDate date;
- date.Set();
- wxPrintf(_T("Today is %s\n"), date.FormatDate(flags).c_str());
- for ( int n = 0; n < 7; n++ )
+ wxFileInputStream fsIn(_T("testdata.fc"));
+ if ( !fsIn.Ok() )
{
- wxPrintf(_T("Previous %s is %s\n"),
- wxDateTime::GetWeekDayName((wxDateTime::WeekDay)n),
- date.Previous(n + 1).FormatDate(flags).c_str());
+ wxPuts(_T("ERROR: couldn't open file."));
}
-}
+ else
+ {
+ wxTextInputStream tis(fsIn);
-#endif // 0
+ size_t line = 1;
+ for ( ;; )
+ {
+ const wxString s = tis.ReadLine();
-#endif // TEST_DATETIME
+ // line could be non empty if the last line of the file isn't
+ // terminated with EOL
+ if ( fsIn.Eof() && s.empty() )
+ break;
+
+ wxPrintf(_T("Line %d: %s\n"), line++, s.c_str());
+ }
+ }
+}
+
+#endif // TEST_TEXTSTREAM
// ----------------------------------------------------------------------------
// threads
{
m_n = n;
m_ch = ch;
- m_cancelled = FALSE;
+ m_cancelled = false;
Create();
}
size_t m_n; // number of characters to write
wxChar m_ch; // character to write
- bool m_cancelled; // FALSE if we exit normally
+ bool m_cancelled; // false if we exit normally
};
wxThread::ExitCode MyDetachedThread::Entry()
{
if ( TestDestroy() )
{
- m_cancelled = TRUE;
+ m_cancelled = true;
break;
}
{
wxString prefix = prefixes[n], rest;
bool rc = s.StartsWith(prefix, &rest);
- wxPrintf(_T("StartsWith('%s') = %s"), prefix.c_str(), rc ? _T("TRUE") : _T("FALSE"));
+ wxPrintf(_T("StartsWith('%s') = %s"), prefix.c_str(), rc ? _T("true") : _T("false"));
if ( rc )
{
wxPrintf(_T(" (the rest is '%s')\n"), rest.c_str());
PrintArray(_T("a1"), a1);
wxPuts(_T("*** After sorting a1 in reverse order"));
- a1.Sort(TRUE);
+ a1.Sort(true);
PrintArray(_T("a1"), a1);
wxPuts(_T("*** After sorting a1 by the string length"));
if ( TEST_ALL )
{
TestDirExists();
- TestDirTraverse();
+ TestDirEnum();
}
- TestDirEnum();
+ TestDirTraverse();
#endif // TEST_DIR
#ifdef TEST_DLLLOADER
#endif // TEST_LOCALE
#ifdef TEST_LOG
+ wxPuts(_T("*** Testing wxLog ***"));
+
wxString s;
for ( size_t n = 0; n < 8000; n++ )
{
s << (wxChar)(_T('A') + (n % 26));
}
+ wxLogWarning(_T("The length of the string is %lu"),
+ (unsigned long)s.length());
+
wxString msg;
msg.Printf(_T("A very very long message: '%s', the end!\n"), s.c_str());
{
TestFileNameConstruction();
TestFileNameMakeRelative();
+ TestFileNameMakeAbsolute();
TestFileNameSplit();
TestFileNameTemp();
TestFileNameCwd();
TestLongLongConversion();
TestBitOperations();
TestLongLongComparison();
- TestLongLongPrint();
+ TestLongLongToString();
+ TestLongLongPrintf();
}
#endif // TEST_LONGLONG
TestMemoryStream();
#endif // TEST_STREAMS
+#ifdef TEST_TEXTSTREAM
+ TestTextInputStream();
+#endif // TEST_TEXTSTREAM
+
#ifdef TEST_THREADS
int nCPUs = wxThread::GetCPUCount();
wxPrintf(_T("This system has %d CPUs\n"), nCPUs);
TestTimeZoneBug();
}
- TestTimeFormat();
+
+ TestTimeWNumber();
if ( TEST_INTERACTIVE )
TestDateTimeInteractive();