X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ccd6aacd5dce43fd10cb49aa1908d8386c17688c..d46a35d092ee017ed32d8c39f76a0643a982d04a:/samples/console/console.cpp diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 76c7cef46a..5165ec811f 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: samples/console/console.cpp -// Purpose: a sample console (as opposed to GUI) progam using wxWidgets +// Purpose: A sample console (as opposed to GUI) program using wxWidgets // Author: Vadim Zeitlin // Modified by: // Created: 04.10.99 @@ -9,6 +9,57 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// +// IMPORTANT NOTE FOR WXWIDGETS USERS: +// If you're a wxWidgets user and you're looking at this file to learn how to +// structure a wxWidgets console application, then you don't have much to learn. +// This application is used more for testing rather than as sample but +// basically the following simple block is enough for you to start your +// own console application: + +/* + int main(int argc, char **argv) + { + wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); + + wxInitializer initializer; + if ( !initializer ) + { + fprintf(stderr, "Failed to initialize the wxWidgets library, aborting."); + return -1; + } + + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_SWITCH, "h", "help", "show this help message", + wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, + // ... your other command line options here... + + { wxCMD_LINE_NONE } + }; + + wxCmdLineParser parser(cmdLineDesc, argc, wxArgv); + switch ( parser.Parse() ) + { + case -1: + wxLogMessage(_T("Help was given, terminating.")); + break; + + case 0: + // everything is ok; proceed + break; + + default: + wxLogMessage(_T("Syntax error detected, aborting.")); + break; + } + + // do something useful here + + return 0; + } +*/ + + // ============================================================================ // declarations // ============================================================================ @@ -23,8 +74,12 @@ #include "wx/string.h" #include "wx/file.h" +#include "wx/filename.h" #include "wx/app.h" #include "wx/log.h" +#include "wx/apptrait.h" +#include "wx/platinfo.h" +#include "wx/wxchar.h" // without this pragma, the stupid compiler precompiles #defines below so that // changing them doesn't "take place" later! @@ -46,31 +101,26 @@ // what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single // test, define it to 1 to do all tests. -#define TEST_ALL 0 +#define TEST_ALL 1 #if TEST_ALL - #define TEST_CMDLINE #define TEST_DATETIME #define TEST_DIR - #define TEST_DLLLOADER + #define TEST_DYNLIB #define TEST_ENVIRON - #define TEST_EXECUTE #define TEST_FILE #define TEST_FILECONF #define TEST_FILENAME #define TEST_FILETIME - // #define TEST_FTP --FIXME! (RN) - #define TEST_HASHMAP - #define TEST_HASHSET + #define TEST_FTP #define TEST_INFO_FUNCTIONS - #define TEST_LIST #define TEST_LOCALE #define TEST_LOG #define TEST_MIME + #define TEST_MODULE #define TEST_PATHLIST - #define TEST_ODBC #define TEST_PRINTF #define TEST_REGCONF #define TEST_REGEX @@ -78,19 +128,17 @@ #define TEST_SCOPEGUARD #define TEST_SNGLINST // #define TEST_SOCKETS --FIXME! (RN) + #define TEST_STACKWALKER + #define TEST_STDPATHS #define TEST_STREAMS #define TEST_TEXTSTREAM #define TEST_THREADS #define TEST_TIMER - // #define TEST_VCARD -- don't enable this (VZ) // #define TEST_VOLUME --FIXME! (RN) #define TEST_WCHAR #define TEST_ZIP - #else // #if TEST_ALL - - #define TEST_DATETIME - + #define TEST_FTP #endif // some tests are interactive, define this to run them @@ -102,33 +150,6 @@ #define TEST_INTERACTIVE 0 #endif -// ---------------------------------------------------------------------------- -// test class for container objects -// ---------------------------------------------------------------------------- - -#if defined(TEST_LIST) - -class Bar // Foo is already taken in the hash test -{ -public: - Bar(const wxString& name) : m_name(name) { ms_bars++; } - Bar(const Bar& bar) : m_name(bar.m_name) { ms_bars++; } - ~Bar() { ms_bars--; } - - static size_t GetNumber() { return ms_bars; } - - const wxChar *GetName() const { return m_name; } - -private: - wxString m_name; - - static size_t ms_bars; -}; - -size_t Bar::ms_bars = 0; - -#endif // defined(TEST_LIST) - // ============================================================================ // implementation // ============================================================================ @@ -165,7 +186,7 @@ static wxString MakePrintable(const wxChar *s) static void ShowCmdLine(const wxCmdLineParser& parser) { - wxString s = _T("Input files: "); + wxString s = _T("Command line parsed successfully:\nInput files: "); size_t count = parser.GetParamCount(); for ( size_t param = 0; param < count; param++ ) @@ -179,6 +200,7 @@ static void ShowCmdLine(const wxCmdLineParser& parser) wxString strVal; long lVal; + double dVal; wxDateTime dt; if ( parser.Found(_T("o"), &strVal) ) s << _T("Output file:\t") << strVal << '\n'; @@ -186,6 +208,8 @@ static void ShowCmdLine(const wxCmdLineParser& parser) s << _T("Input dir:\t") << strVal << '\n'; if ( parser.Found(_T("s"), &lVal) ) s << _T("Size:\t") << lVal << '\n'; + if ( parser.Found(_T("f"), &dVal) ) + s << _T("Double:\t") << dVal << '\n'; if ( parser.Found(_T("d"), &dt) ) s << _T("Date:\t") << dt.FormatISODate() << '\n'; if ( parser.Found(_T("project_name"), &strVal) ) @@ -233,7 +257,7 @@ static void TestCmdLineConvert() #ifdef __UNIX__ static const wxChar *ROOTDIR = _T("/"); static const wxChar *TESTDIR = _T("/usr/local/share"); -#elif defined(__WXMSW__) +#elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__) static const wxChar *ROOTDIR = _T("c:\\"); static const wxChar *TESTDIR = _T("d:\\"); #else @@ -260,6 +284,8 @@ static void TestDirEnumHelper(wxDir& dir, wxPuts(wxEmptyString); } +#if TEST_ALL + static void TestDirEnum() { wxPuts(_T("*** Testing wxDir::GetFirst/GetNext ***")); @@ -315,6 +341,8 @@ static void TestDirEnum() TestDirEnumHelper(dirNo); } +#endif // TEST_ALL + class DirPrintTraverser : public wxDirTraverser { public: @@ -326,7 +354,7 @@ public: virtual wxDirTraverseResult OnDir(const wxString& dirname) { wxString path, name, ext; - wxSplitPath(dirname, &path, &name, &ext); + wxFileName::SplitPath(dirname, &path, &name, &ext); if ( !ext.empty() ) name << _T('.') << ext; @@ -365,6 +393,8 @@ static void TestDirTraverse() dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN); } +#if TEST_ALL + static void TestDirExists() { wxPuts(_T("*** Testing wxDir::Exists() ***")); @@ -398,13 +428,15 @@ static void TestDirExists() } } +#endif // TEST_ALL + #endif // TEST_DIR // ---------------------------------------------------------------------------- // wxDllLoader // ---------------------------------------------------------------------------- -#ifdef TEST_DLLLOADER +#ifdef TEST_DYNLIB #include "wx/dynlib.h" @@ -415,13 +447,13 @@ static void TestDllLoad() static const wxChar *FUNC_NAME = _T("lstrlenA"); #elif defined(__UNIX__) // weird: using just libc.so does *not* work! - static const wxChar *LIB_NAME = _T("/lib/libc-2.0.7.so"); + static const wxChar *LIB_NAME = _T("/lib/libc.so.6"); static const wxChar *FUNC_NAME = _T("strlen"); #else #error "don't know how to test wxDllLoader on this platform" #endif - wxPuts(_T("*** testing wxDllLoader ***\n")); + wxPuts(_T("*** testing basic wxDynamicLibrary functions ***\n")); wxDynamicLibrary lib(LIB_NAME); if ( !lib.IsLoaded() ) @@ -430,7 +462,7 @@ static void TestDllLoad() } else { - typedef int (*wxStrlenType)(const char *); + typedef int (wxSTDCALL *wxStrlenType)(const char *); wxStrlenType pfnStrlen = (wxStrlenType)lib.GetSymbol(FUNC_NAME); if ( !pfnStrlen ) { @@ -439,6 +471,9 @@ static void TestDllLoad() } else { + wxPrintf(_T("Calling %s dynamically loaded from %s "), + FUNC_NAME, LIB_NAME); + if ( pfnStrlen("foo") != 3 ) { wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n")); @@ -448,10 +483,58 @@ static void TestDllLoad() wxPuts(_T("... ok")); } } + +#ifdef __WXMSW__ + static const wxChar *FUNC_NAME_AW = _T("lstrlen"); + + typedef int (wxSTDCALL *wxStrlenTypeAorW)(const wxChar *); + wxStrlenTypeAorW + pfnStrlenAorW = (wxStrlenTypeAorW)lib.GetSymbolAorW(FUNC_NAME_AW); + if ( !pfnStrlenAorW ) + { + wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"), + FUNC_NAME_AW, LIB_NAME); + } + else + { + if ( pfnStrlenAorW(_T("foobar")) != 6 ) + { + wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n")); + } + } +#endif // __WXMSW__ } } -#endif // TEST_DLLLOADER +#if defined(__WXMSW__) || defined(__UNIX__) + +static void TestDllListLoaded() +{ + wxPuts(_T("*** testing wxDynamicLibrary::ListLoaded() ***\n")); + + puts("\nLoaded modules:"); + wxDynamicLibraryDetailsArray dlls = wxDynamicLibrary::ListLoaded(); + const size_t count = dlls.GetCount(); + for ( size_t n = 0; n < count; ++n ) + { + const wxDynamicLibraryDetails& details = dlls[n]; + printf("%-45s", (const char *)details.GetPath().mb_str()); + + void *addr wxDUMMY_INITIALIZE(NULL); + size_t len wxDUMMY_INITIALIZE(0); + if ( details.GetAddress(&addr, &len) ) + { + printf(" %08lx:%08lx", + (unsigned long)addr, (unsigned long)((char *)addr + len)); + } + + printf(" %s\n", (const char *)details.GetVersion().mb_str()); + } +} + +#endif + +#endif // TEST_DYNLIB // ---------------------------------------------------------------------------- // wxGet/SetEnv @@ -490,73 +573,6 @@ static void TestEnvironment() #endif // TEST_ENVIRON -// ---------------------------------------------------------------------------- -// wxExecute -// ---------------------------------------------------------------------------- - -#ifdef TEST_EXECUTE - -#include "wx/utils.h" - -static void TestExecute() -{ - wxPuts(_T("*** testing wxExecute ***")); - -#ifdef __UNIX__ - #define COMMAND "cat -n ../../Makefile" // "echo hi" - #define SHELL_COMMAND "echo hi from shell" - #define REDIRECT_COMMAND COMMAND // "date" -#elif defined(__WXMSW__) - #define COMMAND "command.com /c echo hi" - #define SHELL_COMMAND "echo hi" - #define REDIRECT_COMMAND COMMAND -#else - #error "no command to exec" -#endif // OS - - wxPrintf(_T("Testing wxShell: ")); - fflush(stdout); - if ( wxShell(_T(SHELL_COMMAND)) ) - wxPuts(_T("Ok.")); - else - wxPuts(_T("ERROR.")); - - wxPrintf(_T("Testing wxExecute: ")); - fflush(stdout); - if ( wxExecute(_T(COMMAND), true /* sync */) == 0 ) - wxPuts(_T("Ok.")); - else - wxPuts(_T("ERROR.")); - -#if 0 // no, it doesn't work (yet?) - wxPrintf(_T("Testing async wxExecute: ")); - fflush(stdout); - if ( wxExecute(COMMAND) != 0 ) - wxPuts(_T("Ok (command launched).")); - else - wxPuts(_T("ERROR.")); -#endif // 0 - - wxPrintf(_T("Testing wxExecute with redirection:\n")); - wxArrayString output; - if ( wxExecute(_T(REDIRECT_COMMAND), output) != 0 ) - { - wxPuts(_T("ERROR.")); - } - else - { - size_t count = output.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - wxPrintf(_T("\t%s\n"), output[n].c_str()); - } - - wxPuts(_T("Ok.")); - } -} - -#endif // TEST_EXECUTE - // ---------------------------------------------------------------------------- // file // ---------------------------------------------------------------------------- @@ -578,12 +594,12 @@ static void TestFileRead() wxPuts(_T("File dump:\n----------")); - static const off_t len = 1024; + static const size_t len = 1024; wxChar buf[len]; for ( ;; ) { - off_t nRead = file.Read(buf, len); - if ( nRead == wxInvalidOffset ) + size_t nRead = file.Read(buf, len); + if ( nRead == (size_t)wxInvalidOffset ) { wxPrintf(_T("Failed to read the file.")); break; @@ -690,6 +706,24 @@ static void TestFileCopy() wxPuts(wxEmptyString); } +static void TestTempFile() +{ + wxPuts(_T("*** wxTempFile test ***")); + + wxTempFile tmpFile; + if ( tmpFile.Open(_T("test2")) && tmpFile.Write(_T("the answer is 42")) ) + { + if ( tmpFile.Commit() ) + wxPuts(_T("File committed.")); + else + wxPuts(_T("ERROR: could't commit temp file.")); + + wxRemoveFile(_T("test2")); + } + + wxPuts(wxEmptyString); +} + #endif // TEST_FILE // ---------------------------------------------------------------------------- @@ -804,116 +838,6 @@ static void DumpFileName(const wxChar *desc, const wxFileName& fn) } #endif -static struct FileNameInfo -{ - const wxChar *fullname; - const wxChar *volume; - const wxChar *path; - const wxChar *name; - const wxChar *ext; - bool isAbsolute; - wxPathFormat format; -} 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 }, - - // 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 }, - - // 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 }, -#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 }, -}; - -static void TestFileNameConstruction() -{ - wxPuts(_T("*** testing wxFileName construction ***")); - - for ( size_t n = 0; n < WXSIZEOF(filenames); n++ ) - { - const FileNameInfo& fni = filenames[n]; - - wxFileName fn(fni.fullname, fni.format); - - wxString fullname = fn.GetFullPath(fni.format); - if ( fullname != fni.fullname ) - { - wxPrintf(_T("ERROR: fullname should be '%s'\n"), fni.fullname); - } - - bool isAbsolute = fn.IsAbsolute(fni.format); - wxPrintf(_T("'%s' is %s (%s)\n\t"), - fullname.c_str(), - isAbsolute ? "absolute" : "relative", - isAbsolute == fni.isAbsolute ? "ok" : "ERROR"); - - if ( !fn.Normalize(wxPATH_NORM_ALL, wxEmptyString, fni.format) ) - { - wxPuts(_T("ERROR (couldn't be normalized)")); - } - else - { - wxPrintf(_T("normalized: '%s'\n"), fn.GetFullPath(fni.format).c_str()); - } - } - - wxPuts(wxEmptyString); -} - -static void TestFileNameSplit() -{ - wxPuts(_T("*** testing wxFileName splitting ***")); - - for ( size_t n = 0; n < WXSIZEOF(filenames); n++ ) - { - const FileNameInfo& fni = filenames[n]; - wxString volume, path, name, ext; - wxFileName::SplitPath(fni.fullname, - &volume, &path, &name, &ext, fni.format); - - wxPrintf(_T("%s -> volume = '%s', path = '%s', name = '%s', ext = '%s'"), - fni.fullname, - volume.c_str(), path.c_str(), name.c_str(), ext.c_str()); - - if ( volume != fni.volume ) - wxPrintf(_T(" (ERROR: volume = '%s')"), fni.volume); - if ( path != fni.path ) - wxPrintf(_T(" (ERROR: path = '%s')"), fni.path); - if ( name != fni.name ) - wxPrintf(_T(" (ERROR: name = '%s')"), fni.name); - if ( ext != fni.ext ) - wxPrintf(_T(" (ERROR: ext = '%s')"), fni.ext); - - wxPuts(wxEmptyString); - } -} - static void TestFileNameTemp() { wxPuts(_T("*** testing wxFileName temp file creation ***")); @@ -952,70 +876,6 @@ static void TestFileNameTemp() } } -static void TestFileNameMakeRelative() -{ - wxPuts(_T("*** testing wxFileName::MakeRelativeTo() ***")); - - for ( size_t n = 0; n < WXSIZEOF(filenames); n++ ) - { - const FileNameInfo& fni = filenames[n]; - - wxFileName fn(fni.fullname, fni.format); - - // choose the base dir of the same format - wxString base; - switch ( fni.format ) - { - case wxPATH_UNIX: - base = _T("/usr/bin/"); - break; - - case wxPATH_DOS: - base = _T("c:\\"); - break; - - case wxPATH_MAC: - case wxPATH_VMS: - // TODO: I don't know how this is supposed to work there - continue; - - case wxPATH_NATIVE: // make gcc happy - default: - wxFAIL_MSG( _T("unexpected path format") ); - } - - wxPrintf(_T("'%s' relative to '%s': "), - fn.GetFullPath(fni.format).c_str(), base.c_str()); - - if ( !fn.MakeRelativeTo(base, fni.format) ) - { - wxPuts(_T("unchanged")); - } - else - { - wxPrintf(_T("'%s'\n"), fn.GetFullPath(fni.format).c_str()); - } - } -} - -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(wxEmptyString); -} - static void TestFileNameDirManip() { // TODO: test AppendDir(), RemoveDir(), ... @@ -1044,8 +904,8 @@ static void TestFileNameCwd() #ifdef TEST_FILETIME -#include -#include +#include "wx/filename.h" +#include "wx/datetime.h" static void TestFileGetTimes() { @@ -1081,386 +941,6 @@ static void TestFileSetTimes() #endif // TEST_FILETIME -// ---------------------------------------------------------------------------- -// wxHashMap -// ---------------------------------------------------------------------------- - -#ifdef TEST_HASHMAP - -#include "wx/hashmap.h" - -// test compilation of basic map types -WX_DECLARE_HASH_MAP( int*, int*, wxPointerHash, wxPointerEqual, myPtrHashMap ); -WX_DECLARE_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual, myLongHashMap ); -WX_DECLARE_HASH_MAP( unsigned long, unsigned, wxIntegerHash, wxIntegerEqual, - myUnsignedHashMap ); -WX_DECLARE_HASH_MAP( unsigned int, unsigned, wxIntegerHash, wxIntegerEqual, - myTestHashMap1 ); -WX_DECLARE_HASH_MAP( int, unsigned, wxIntegerHash, wxIntegerEqual, - myTestHashMap2 ); -WX_DECLARE_HASH_MAP( short, unsigned, wxIntegerHash, wxIntegerEqual, - myTestHashMap3 ); -WX_DECLARE_HASH_MAP( unsigned short, unsigned, wxIntegerHash, wxIntegerEqual, - myTestHashMap4 ); - -// same as: -// WX_DECLARE_HASH_MAP( wxString, wxString, wxStringHash, wxStringEqual, -// myStringHashMap ); -WX_DECLARE_STRING_HASH_MAP(wxString, myStringHashMap); - -typedef myStringHashMap::iterator Itor; - -static void TestHashMap() -{ - wxPuts(_T("*** Testing wxHashMap ***\n")); - myStringHashMap sh(0); // as small as possible - wxString buf; - size_t i; - const size_t count = 10000; - - // init with some data - for( i = 0; i < count; ++i ) - { - buf.Printf(wxT("%d"), i ); - sh[buf] = wxT("A") + buf + wxT("C"); - } - - // test that insertion worked - if( sh.size() != count ) - { - wxPrintf(_T("*** ERROR: %u ELEMENTS, SHOULD BE %u ***\n"), sh.size(), count); - } - - for( i = 0; i < count; ++i ) - { - buf.Printf(wxT("%d"), i ); - if( sh[buf] != wxT("A") + buf + wxT("C") ) - { - wxPrintf(_T("*** ERROR INSERTION BROKEN! STOPPING NOW! ***\n")); - return; - } - } - - // check that iterators work - Itor it; - for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i ) - { - if( i == count ) - { - wxPrintf(_T("*** ERROR ITERATORS DO NOT TERMINATE! STOPPING NOW! ***\n")); - return; - } - - if( it->second != sh[it->first] ) - { - wxPrintf(_T("*** ERROR ITERATORS BROKEN! STOPPING NOW! ***\n")); - return; - } - } - - if( sh.size() != i ) - { - wxPrintf(_T("*** ERROR: %u ELEMENTS ITERATED, SHOULD BE %u ***\n"), i, count); - } - - // test copy ctor, assignment operator - myStringHashMap h1( sh ), h2( 0 ); - h2 = sh; - - for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i ) - { - if( h1[it->first] != it->second ) - { - wxPrintf(_T("*** ERROR: COPY CTOR BROKEN %s ***\n"), it->first.c_str()); - } - - if( h2[it->first] != it->second ) - { - wxPrintf(_T("*** ERROR: OPERATOR= BROKEN %s ***\n"), it->first.c_str()); - } - } - - // other tests - for( i = 0; i < count; ++i ) - { - buf.Printf(wxT("%d"), i ); - size_t sz = sh.size(); - - // test find() and erase(it) - if( i < 100 ) - { - it = sh.find( buf ); - if( it != sh.end() ) - { - sh.erase( it ); - - if( sh.find( buf ) != sh.end() ) - { - wxPrintf(_T("*** ERROR: FOUND DELETED ELEMENT %u ***\n"), i); - } - } - else - wxPrintf(_T("*** ERROR: CANT FIND ELEMENT %u ***\n"), i); - } - else - // test erase(key) - { - size_t c = sh.erase( buf ); - if( c != 1 ) - wxPrintf(_T("*** ERROR: SHOULD RETURN 1 ***\n")); - - if( sh.find( buf ) != sh.end() ) - { - wxPrintf(_T("*** ERROR: FOUND DELETED ELEMENT %u ***\n"), i); - } - } - - // count should decrease - if( sh.size() != sz - 1 ) - { - wxPrintf(_T("*** ERROR: COUNT DID NOT DECREASE ***\n")); - } - } - - wxPrintf(_T("*** Finished testing wxHashMap ***\n")); -} - -#endif // TEST_HASHMAP - -// ---------------------------------------------------------------------------- -// wxHashSet -// ---------------------------------------------------------------------------- - -#ifdef TEST_HASHSET - -#include "wx/hashset.h" - -// test compilation of basic map types -WX_DECLARE_HASH_SET( int*, wxPointerHash, wxPointerEqual, myPtrHashSet ); -WX_DECLARE_HASH_SET( long, wxIntegerHash, wxIntegerEqual, myLongHashSet ); -WX_DECLARE_HASH_SET( unsigned long, wxIntegerHash, wxIntegerEqual, - myUnsignedHashSet ); -WX_DECLARE_HASH_SET( unsigned int, wxIntegerHash, wxIntegerEqual, - myTestHashSet1 ); -WX_DECLARE_HASH_SET( int, wxIntegerHash, wxIntegerEqual, - myTestHashSet2 ); -WX_DECLARE_HASH_SET( short, wxIntegerHash, wxIntegerEqual, - myTestHashSet3 ); -WX_DECLARE_HASH_SET( unsigned short, wxIntegerHash, wxIntegerEqual, - myTestHashSet4 ); -WX_DECLARE_HASH_SET( wxString, wxStringHash, wxStringEqual, - myTestHashSet5 ); - -struct MyStruct -{ - int* ptr; - wxString str; -}; - -class MyHash -{ -public: - unsigned long operator()(const MyStruct& s) const - { return m_dummy(s.ptr); } - MyHash& operator=(const MyHash&) { return *this; } -private: - wxPointerHash m_dummy; -}; - -class MyEqual -{ -public: - bool operator()(const MyStruct& s1, const MyStruct& s2) const - { return s1.ptr == s2.ptr; } - MyEqual& operator=(const MyEqual&) { return *this; } -}; - -WX_DECLARE_HASH_SET( MyStruct, MyHash, MyEqual, mySet ); - -typedef myTestHashSet5 wxStringHashSet; - -static void TestHashSet() -{ - wxPrintf(_T("*** Testing wxHashSet ***\n")); - - wxStringHashSet set1; - - set1.insert( _T("abc") ); - set1.insert( _T("bbc") ); - set1.insert( _T("cbc") ); - set1.insert( _T("abc") ); - - if( set1.size() != 3 ) - wxPrintf(_T("*** ERROR IN INSERT ***\n")); - - mySet set2; - int dummy; - MyStruct tmp; - - tmp.ptr = &dummy; tmp.str = _T("ABC"); - set2.insert( tmp ); - tmp.ptr = &dummy + 1; - set2.insert( tmp ); - tmp.ptr = &dummy; tmp.str = _T("CDE"); - set2.insert( tmp ); - - if( set2.size() != 2 ) - wxPrintf(_T("*** ERROR IN INSERT - 2 ***\n")); - - mySet::iterator it = set2.find( tmp ); - - if( it == set2.end() ) - wxPrintf(_T("*** ERROR IN FIND - 1 ***\n")); - if( it->ptr != &dummy ) - wxPrintf(_T("*** ERROR IN FIND - 2 ***\n")); - if( it->str != _T("ABC") ) - wxPrintf(_T("*** ERROR IN INSERT - 3 ***\n")); - - wxPrintf(_T("*** Finished testing wxHashSet ***\n")); -} - -#endif // TEST_HASHSET - -// ---------------------------------------------------------------------------- -// wxList -// ---------------------------------------------------------------------------- - -#ifdef TEST_LIST - -#include "wx/list.h" - -WX_DECLARE_LIST(Bar, wxListBars); -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxListBars); - -WX_DECLARE_LIST(int, wxListInt); -WX_DEFINE_LIST(wxListInt); - -static void TestList() -{ - wxPuts(_T("*** Testing wxList operations ***\n")); - { - wxListInt list1; - int dummy[5]; - int i; - - for ( i = 0; i < 5; ++i ) - list1.Append(dummy + i); - - if ( list1.GetCount() != 5 ) - wxPuts(_T("Wrong number of items in list\n")); - - if ( list1.Item(3)->GetData() != dummy + 3 ) - wxPuts(_T("Error in Item()\n")); - - if ( !list1.Find(dummy + 4) ) - wxPuts(_T("Error in Find()\n")); - - wxListInt::compatibility_iterator node = list1.GetFirst(); - i = 0; - - while (node) - { - if ( node->GetData() != dummy + i ) - wxPuts(_T("Error in compatibility_iterator\n")); - node = node->GetNext(); - ++i; - } - - if ( size_t(i) != list1.GetCount() ) - wxPuts(_T("Error in compatibility_iterator\n")); - - list1.Insert(dummy + 0); - list1.Insert(1, dummy + 1); - list1.Insert(list1.GetFirst()->GetNext()->GetNext(), dummy + 2); - - node = list1.GetFirst(); - i = 0; - - while (i < 3) - { - int* t = node->GetData(); - if ( t != dummy + i ) - wxPuts(_T("Error in Insert\n")); - node = node->GetNext(); - ++i; - } - } - - wxPuts(_T("*** Testing wxList operations finished ***\n")); - - wxPuts(_T("*** Testing std::list operations ***\n")); - - { - wxListInt list1; - wxListInt::iterator it, en; - wxListInt::reverse_iterator rit, ren; - int i; - for ( i = 0; i < 5; ++i ) - list1.push_back(i + &i); - - for ( it = list1.begin(), en = list1.end(), i = 0; - it != en; ++it, ++i ) - if ( *it != i + &i ) - wxPuts(_T("Error in iterator\n")); - - for ( rit = list1.rbegin(), ren = list1.rend(), i = 4; - rit != ren; ++rit, --i ) - if ( *rit != i + &i ) - wxPuts(_T("Error in reverse_iterator\n")); - - if ( *list1.rbegin() != *--list1.end() || - *list1.begin() != *--list1.rend() ) - wxPuts(_T("Error in iterator/reverse_iterator\n")); - if ( *list1.begin() != *--++list1.begin() || - *list1.rbegin() != *--++list1.rbegin() ) - wxPuts(_T("Error in iterator/reverse_iterator\n")); - - if ( list1.front() != &i || list1.back() != &i + 4 ) - wxPuts(_T("Error in front()/back()\n")); - - list1.erase(list1.begin()); - list1.erase(--list1.end()); - - for ( it = list1.begin(), en = list1.end(), i = 1; - it != en; ++it, ++i ) - if ( *it != i + &i ) - wxPuts(_T("Error in erase()\n")); - } - - wxPuts(_T("*** Testing std::list operations finished ***\n")); -} - -static void TestListCtor() -{ - wxPuts(_T("*** Testing wxList construction ***\n")); - - { - wxListBars list1; - list1.Append(new Bar(_T("first"))); - list1.Append(new Bar(_T("second"))); - - wxPrintf(_T("After 1st list creation: %u objects in the list, %u objects total.\n"), - list1.GetCount(), Bar::GetNumber()); - - wxListBars list2; - list2 = list1; - - wxPrintf(_T("After 2nd list creation: %u and %u objects in the lists, %u objects total.\n"), - list1.GetCount(), list2.GetCount(), Bar::GetNumber()); - -#if !wxUSE_STL - list1.DeleteContents(true); -#else - WX_CLEAR_LIST(wxListBars, list1); -#endif - } - - wxPrintf(_T("After list destruction: %u objects left.\n"), Bar::GetNumber()); -} - -#endif // TEST_LIST - // ---------------------------------------------------------------------------- // wxLocale // ---------------------------------------------------------------------------- @@ -1470,7 +950,10 @@ static void TestListCtor() #include "wx/intl.h" #include "wx/utils.h" // for wxSetEnv -static wxLocale gs_localeDefault(wxLANGUAGE_ENGLISH); +static wxLocale gs_localeDefault; + // NOTE: don't init it here as it needs a wxAppTraits object + // and thus must be init-ed after creation of the wxInitializer + // class in the main() // find the name of the language from its value static const wxChar *GetLangName(int lang) @@ -1719,6 +1202,8 @@ static void TestDefaultLang() { wxPuts(_T("*** Testing wxLocale::GetSystemLanguage ***")); + gs_localeDefault.Init(wxLANGUAGE_ENGLISH); + static const wxChar *langStrings[] = { NULL, // system default @@ -1808,32 +1293,6 @@ static void TestMimeEnum() 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")); @@ -1878,6 +1337,35 @@ static void TestMimeFilename() wxPuts(wxEmptyString); } +// these tests were broken by wxMimeTypesManager changes, temporarily disabling +#if 0 + +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 TestMimeAssociate() { wxPuts(_T("*** Testing creation of filetype association ***\n")); @@ -1888,7 +1376,7 @@ static void TestMimeAssociate() _T(""), // print cmd _T("XYZ File"), // description _T(".xyz"), // extensions - NULL // end of extensions + wxNullPtr // end of extensions ); ftInfo.SetShortDesc(_T("XYZFile")); // used under Win32 only @@ -1906,8 +1394,84 @@ static void TestMimeAssociate() wxPuts(wxEmptyString); } +#endif // 0 + #endif // TEST_MIME +// ---------------------------------------------------------------------------- +// module dependencies feature +// ---------------------------------------------------------------------------- + +#ifdef TEST_MODULE + +#include "wx/module.h" + +class wxTestModule : public wxModule +{ +protected: + virtual bool OnInit() { wxPrintf(_T("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; } + virtual void OnExit() { wxPrintf(_T("Unload module: %s\n"), GetClassInfo()->GetClassName()); } +}; + +class wxTestModuleA : public wxTestModule +{ +public: + wxTestModuleA(); +private: + DECLARE_DYNAMIC_CLASS(wxTestModuleA) +}; + +class wxTestModuleB : public wxTestModule +{ +public: + wxTestModuleB(); +private: + DECLARE_DYNAMIC_CLASS(wxTestModuleB) +}; + +class wxTestModuleC : public wxTestModule +{ +public: + wxTestModuleC(); +private: + DECLARE_DYNAMIC_CLASS(wxTestModuleC) +}; + +class wxTestModuleD : public wxTestModule +{ +public: + wxTestModuleD(); +private: + DECLARE_DYNAMIC_CLASS(wxTestModuleD) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC, wxModule) +wxTestModuleC::wxTestModuleC() +{ + AddDependency(CLASSINFO(wxTestModuleD)); +} + +IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA, wxModule) +wxTestModuleA::wxTestModuleA() +{ + AddDependency(CLASSINFO(wxTestModuleB)); + AddDependency(CLASSINFO(wxTestModuleD)); +} + +IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD, wxModule) +wxTestModuleD::wxTestModuleD() +{ +} + +IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB, wxModule) +wxTestModuleB::wxTestModuleB() +{ + AddDependency(CLASSINFO(wxTestModuleD)); + AddDependency(CLASSINFO(wxTestModuleC)); +} + +#endif // TEST_MODULE + // ---------------------------------------------------------------------------- // misc information functions // ---------------------------------------------------------------------------- @@ -1916,6 +1480,7 @@ static void TestMimeAssociate() #include "wx/utils.h" +#if TEST_INTERACTIVE static void TestDiskInfo() { wxPuts(_T("*** Testing wxGetDiskSpace() ***")); @@ -1944,6 +1509,7 @@ static void TestDiskInfo() } } } +#endif // TEST_INTERACTIVE static void TestOsInfo() { @@ -1954,7 +1520,7 @@ static void TestOsInfo() 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("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong()); wxPrintf(_T("Host name is %s (%s).\n"), wxGetHostName().c_str(), wxGetFullHostName().c_str()); @@ -1962,6 +1528,23 @@ static void TestOsInfo() wxPuts(wxEmptyString); } +static void TestPlatformInfo() +{ + wxPuts(_T("*** Testing wxPlatformInfo functions ***\n")); + + // get this platform + wxPlatformInfo plat; + + wxPrintf(_T("Operating system family name is: %s\n"), plat.GetOperatingSystemFamilyName().c_str()); + wxPrintf(_T("Operating system name is: %s\n"), plat.GetOperatingSystemIdName().c_str()); + wxPrintf(_T("Port ID name is: %s\n"), plat.GetPortIdName().c_str()); + wxPrintf(_T("Port ID short name is: %s\n"), plat.GetPortIdShortName().c_str()); + wxPrintf(_T("Architecture is: %s\n"), plat.GetArchName().c_str()); + wxPrintf(_T("Endianness is: %s\n"), plat.GetEndiannessName().c_str()); + + wxPuts(wxEmptyString); +} + static void TestUserInfo() { wxPuts(_T("*** Testing user info functions ***\n")); @@ -2011,7 +1594,7 @@ static void TestPathList() // regular expressions // ---------------------------------------------------------------------------- -#ifdef TEST_REGEX +#if defined TEST_REGEX && TEST_INTERACTIVE #include "wx/regex.h" @@ -2071,26 +1654,6 @@ static void TestRegExInteractive() #endif // TEST_REGEX -// ---------------------------------------------------------------------------- -// database -// ---------------------------------------------------------------------------- - -#if !wxUSE_ODBC - #undef TEST_ODBC -#endif - -#ifdef TEST_ODBC - -#include - -static void TestDbOpen() -{ - HENV henv; - wxDb db(henv); -} - -#endif // TEST_ODBC - // ---------------------------------------------------------------------------- // printf() tests // ---------------------------------------------------------------------------- @@ -2108,7 +1671,7 @@ static void TestDbOpen() #undef wxPrintf #undef wxSprintf - // NB: do _not_ use ATTRIBUTE_PRINTF here, we have some invalid formats + // NB: do _not_ use WX_ATTRIBUTE_PRINTF here, we have some invalid formats // in the tests below int wxPrintf( const wxChar *format, ... ); int wxSprintf( wxChar *str, const wxChar *format, ... ); @@ -2493,7 +2056,7 @@ static void TestRegConfWrite() static void TestRegConfRead() { - wxConfig *config = new wxConfig(_T("myapp")); + wxRegConfig *config = new wxRegConfig(_T("myapp")); wxString str; long dummy; @@ -2640,9 +2203,9 @@ static void TestScopeGuard() 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'); + 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(); @@ -2803,11 +2366,12 @@ static void TestSocketClient() #ifdef TEST_FTP #include "wx/protocol/ftp.h" - -static wxFTP ftp; +#include "wx/protocol/log.h" #define FTP_ANONYMOUS +static wxFTP *ftp; + #ifdef FTP_ANONYMOUS static const wxChar *directory = _T("/pub"); static const wxChar *filename = _T("welcome.msg"); @@ -2830,68 +2394,31 @@ static bool TestFtpConnect() wxChar user[256]; wxFgets(user, WXSIZEOF(user), stdin); user[wxStrlen(user) - 1] = '\0'; // chop off '\n' - ftp.SetUser(user); + 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); + 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; - } + 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()); + ftp->Close(); } + + return true; } static void TestFtpList() @@ -2899,22 +2426,22 @@ static void TestFtpList() wxPuts(_T("*** Testing wxFTP file listing ***\n")); // test CWD - if ( !ftp.ChDir(directory) ) + 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()); + wxPrintf(_T("Current directory is '%s'\n"), ftp->Pwd().c_str()); // test NLIST and LIST wxArrayString files; - if ( !ftp.GetFilesList(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()); + 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++ ) { @@ -2923,13 +2450,13 @@ static void TestFtpList() wxPuts(_T("End of the file list")); } - if ( !ftp.GetDirList(files) ) + 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()); + 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++ ) { @@ -2938,12 +2465,12 @@ static void TestFtpList() wxPuts(_T("End of the file list")); } - if ( !ftp.ChDir(_T("..")) ) + if ( !ftp->ChDir(_T("..")) ) { wxPuts(_T("ERROR: failed to cd to ..")); } - wxPrintf(_T("Current directory is '%s'\n"), ftp.Pwd().c_str()); + wxPrintf(_T("Current directory is '%s'\n"), ftp->Pwd().c_str()); } static void TestFtpDownload() @@ -2951,7 +2478,7 @@ static void TestFtpDownload() wxPuts(_T("*** Testing wxFTP download ***\n")); // test RETR - wxInputStream *in = ftp.GetInputStream(filename); + wxInputStream *in = ftp->GetInputStream(filename); if ( !in ) { wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename); @@ -2981,16 +2508,16 @@ static void TestFtpFileSize() { wxPuts(_T("*** Testing FTP SIZE command ***")); - if ( !ftp.ChDir(directory) ) + 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()); + wxPrintf(_T("Current directory is '%s'\n"), ftp->Pwd().c_str()); - if ( ftp.FileExists(filename) ) + if ( ftp->FileExists(filename) ) { - int size = ftp.GetFileSize(filename); + int size = ftp->GetFileSize(filename); if ( size == -1 ) wxPrintf(_T("ERROR: couldn't get size of '%s'\n"), filename); else @@ -3006,26 +2533,28 @@ static void TestFtpMisc() { wxPuts(_T("*** Testing miscellaneous wxFTP functions ***")); - if ( ftp.SendCommand(_T("STAT")) != '2' ) + if ( ftp->SendCommand(_T("STAT")) != '2' ) { wxPuts(_T("ERROR: STAT failed")); } else { - wxPrintf(_T("STAT returned:\n\n%s\n"), ftp.GetLastResult().c_str()); + wxPrintf(_T("STAT returned:\n\n%s\n"), ftp->GetLastResult().c_str()); } - if ( ftp.SendCommand(_T("HELP SITE")) != '2' ) + 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()); + ftp->GetLastResult().c_str()); } } +#if TEST_INTERACTIVE + static void TestFtpInteractive() { wxPuts(_T("\n*** Interactive wxFTP test ***")); @@ -3051,14 +2580,14 @@ static void TestFtpInteractive() wildcard = buf + 5; wxArrayString files; - if ( !ftp.GetList(files, wildcard, start == _T("LIST")) ) + 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()); + start.c_str(), wildcard.c_str(), ftp->Pwd().c_str()); size_t count = files.GetCount(); for ( size_t n = 0; n < count; n++ ) { @@ -3069,20 +2598,22 @@ static void TestFtpInteractive() } else // !list { - wxChar ch = ftp.SendCommand(buf); + 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()); + wxPrintf(_T(", server reply:\n%s\n\n"), ftp->GetLastResult().c_str()); } } wxPuts(_T("\n*** done ***")); } +#endif // TEST_INTERACTIVE + static void TestFtpUpload() { wxPuts(_T("*** Testing wxFTP uploading ***\n")); @@ -3090,7 +2621,7 @@ static void TestFtpUpload() // upload a file static const wxChar *file1 = _T("test1"); static const wxChar *file2 = _T("test2"); - wxOutputStream *out = ftp.GetOutputStream(file1); + wxOutputStream *out = ftp->GetOutputStream(file1); if ( out ) { wxPrintf(_T("--- Uploading to %s ---\n"), file1); @@ -3099,17 +2630,17 @@ static void TestFtpUpload() } // send a command to check the remote file - if ( ftp.SendCommand(wxString(_T("STAT ")) + file1) != '2' ) + 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()); + file1, ftp->GetLastResult().c_str()); } - out = ftp.GetOutputStream(file2); + out = ftp->GetOutputStream(file2); if ( out ) { wxPrintf(_T("--- Uploading to %s ---\n"), file1); @@ -3120,6 +2651,115 @@ static void TestFtpUpload() #endif // TEST_FTP +// ---------------------------------------------------------------------------- +// stack backtrace +// ---------------------------------------------------------------------------- + +#ifdef TEST_STACKWALKER + +#if wxUSE_STACKWALKER + +#include "wx/stackwalk.h" + +class StackDump : public wxStackWalker +{ +public: + StackDump(const char *argv0) + : wxStackWalker(argv0) + { + } + + virtual void Walk(size_t skip = 1, size_t maxdepth = wxSTACKWALKER_MAX_DEPTH) + { + wxPuts(_T("Stack dump:")); + + wxStackWalker::Walk(skip, maxdepth); + } + +protected: + virtual void OnStackFrame(const wxStackFrame& frame) + { + printf("[%2d] ", (int) frame.GetLevel()); + + wxString name = frame.GetName(); + if ( !name.empty() ) + { + printf("%-20.40s", (const char*)name.mb_str()); + } + else + { + printf("0x%08lx", (unsigned long)frame.GetAddress()); + } + + if ( frame.HasSourceLocation() ) + { + printf("\t%s:%d", + (const char*)frame.GetFileName().mb_str(), + (int)frame.GetLine()); + } + + puts(""); + + wxString type, val; + for ( size_t n = 0; frame.GetParam(n, &type, &name, &val); n++ ) + { + printf("\t%s %s = %s\n", (const char*)type.mb_str(), + (const char*)name.mb_str(), + (const char*)val.mb_str()); + } + } +}; + +static void TestStackWalk(const char *argv0) +{ + wxPuts(_T("*** Testing wxStackWalker ***\n")); + + StackDump dump(argv0); + dump.Walk(); +} + +#endif // wxUSE_STACKWALKER + +#endif // TEST_STACKWALKER + +// ---------------------------------------------------------------------------- +// standard paths +// ---------------------------------------------------------------------------- + +#ifdef TEST_STDPATHS + +#include "wx/stdpaths.h" +#include "wx/wxchar.h" // wxPrintf + +static void TestStandardPaths() +{ + wxPuts(_T("*** Testing wxStandardPaths ***\n")); + + wxTheApp->SetAppName(_T("console")); + + wxStandardPathsBase& stdp = wxStandardPaths::Get(); + wxPrintf(_T("Config dir (sys):\t%s\n"), stdp.GetConfigDir().c_str()); + wxPrintf(_T("Config dir (user):\t%s\n"), stdp.GetUserConfigDir().c_str()); + wxPrintf(_T("Data dir (sys):\t\t%s\n"), stdp.GetDataDir().c_str()); + wxPrintf(_T("Data dir (sys local):\t%s\n"), stdp.GetLocalDataDir().c_str()); + wxPrintf(_T("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str()); + wxPrintf(_T("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str()); + wxPrintf(_T("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str()); + wxPrintf(_T("Executable path:\t%s\n"), stdp.GetExecutablePath().c_str()); + wxPrintf(_T("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir().c_str()); + wxPrintf(_T("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str()); + wxPrintf(_T("Localized res. dir:\t%s\n"), + stdp.GetLocalizedResourcesDir(_T("fr")).c_str()); + wxPrintf(_T("Message catalogs dir:\t%s\n"), + stdp.GetLocalizedResourcesDir + ( + _T("fr"), + wxStandardPaths::ResourceCat_Messages + ).c_str()); +} + +#endif // TEST_STDPATHS + // ---------------------------------------------------------------------------- // streams // ---------------------------------------------------------------------------- @@ -3139,11 +2779,14 @@ static void TestFileStream() fsOut.Write("foo", 3); } - wxFileInputStream fsIn(filename); - wxPrintf(_T("File stream size: %u\n"), fsIn.GetSize()); - while ( !fsIn.Eof() ) { - wxPutchar(fsIn.GetC()); + wxFileInputStream fsIn(filename); + wxPrintf(_T("File stream size: %u\n"), fsIn.GetSize()); + int c; + while ( (c=fsIn.GetC()) != wxEOF ) + { + wxPutchar(c); + } } if ( !wxRemoveFile(filename) ) @@ -3177,9 +2820,10 @@ static void TestMemoryStream() wxMemoryInputStream memInpStream(buf, len); wxPrintf(_T("Memory stream size: %u\n"), memInpStream.GetSize()); - while ( !memInpStream.Eof() ) + int c; + while ( (c=memInpStream.GetC()) != wxEOF ) { - wxPutchar(memInpStream.GetC()); + wxPutchar(c); } wxPuts(_T("\n*** wxMemoryInputStream test done ***")); @@ -3193,7 +2837,7 @@ static void TestMemoryStream() #ifdef TEST_TIMER -#include "wx/timer.h" +#include "wx/stopwatch.h" #include "wx/utils.h" static void TestStopWatch() @@ -3246,249 +2890,53 @@ static void TestStopWatch() 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(""); - break; - - default: - value = _T(""); - } - - 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); - } -} +#include "wx/timer.h" +#include "wx/evtloop.h" -static void DumpVCardPhoneNumbers(const wxVCard& vcard) +void TestTimer() { - wxPuts(_T("\nShowing all phone numbers from vCard:\n")); + wxPuts(_T("*** Testing wxTimer ***\n")); - size_t nPhone = 0; - void *cookie; - wxVCardPhoneNumber *phone = vcard.GetFirstPhoneNumber(&cookie); - while ( phone ) + class MyTimer : public wxTimer { - 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")); + public: + MyTimer() : wxTimer() { m_num = 0; } - 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 + virtual void Notify() { - value = _T(""); - } + wxPrintf(_T("%d"), m_num++); + fflush(stdout); - wxPrintf(_T("Full name retrieved directly: %s\n"), value.c_str()); + if ( m_num == 10 ) + { + wxPrintf(_T("... exiting the event loop")); + Stop(); + wxEventLoop::GetActive()->Exit(0); + wxPuts(_T(", ok.")); + } - if ( !vcard.GetFullName(&value) ) - { - value = _T(""); + fflush(stdout); } - 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); + private: + int m_num; + }; - // and finally show all - wxPuts(_T("\nNow dumping the entire vCard:\n") - "-----------------------------\n"); + wxEventLoop loop; - DumpVObject(0, vcard); - } -} + wxTimer timer1; + timer1.Start(100, true /* one shot */); + timer1.Stop(); + timer1.Start(100, true /* one shot */); -static void TestVCardWrite() -{ - wxPuts(_T("*** Testing wxVCard writing ***\n")); + MyTimer timer; + timer.Start(500); - 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("wxWidgets", "R&D"); - - // just dump the vCard back - wxPuts(_T("Entire vCard follows:\n")); - wxPuts(vcard.Write()); - } + loop.Run(); } -#endif // TEST_VCARD +#endif // TEST_TIMER // ---------------------------------------------------------------------------- // wxVolume tests @@ -3682,13 +3130,18 @@ static void TestZipStreamRead() wxPuts(_T("*** Testing ZIP reading ***\n")); static const wxString filename = _T("foo"); - wxZipInputStream istr(TESTFILE_ZIP, filename); + wxFFileInputStream in(TESTFILE_ZIP); + wxZipInputStream istr(in); + wxZipEntry entry(filename); + istr.OpenEntry(entry); + wxPrintf(_T("Archive size: %u\n"), istr.GetSize()); wxPrintf(_T("Dumping the file '%s':\n"), filename.c_str()); - while ( !istr.Eof() ) + int c; + while ( (c=istr.GetC()) != wxEOF ) { - wxPutchar(istr.GetC()); + wxPutchar(c); fflush(stdout); } @@ -3756,11 +3209,13 @@ static void TestZipFileSystem() #ifdef TEST_DATETIME -#include - +#include "wx/math.h" #include "wx/datetime.h" // this test miscellaneous static wxDateTime functions + +#if TEST_ALL + static void TestTimeStatic() { wxPuts(_T("\n*** wxDateTime static methods test ***")); @@ -3839,6 +3294,10 @@ static void TestTimeDST() } } +#endif // TEST_ALL + +#if TEST_INTERACTIVE + static void TestDateTimeInteractive() { wxPuts(_T("\n*** interactive wxDateTime tests ***")); @@ -3878,6 +3337,10 @@ static void TestDateTimeInteractive() wxPuts(_T("\n*** done ***")); } +#endif // TEST_INTERACTIVE + +#if TEST_ALL + static void TestTimeMS() { wxPuts(_T("*** testing millisecond-resolution support in wxDateTime ***")); @@ -3979,6 +3442,8 @@ static void TestTimeSpanFormat() wxPuts(wxEmptyString); } +#endif // TEST_ALL + #endif // TEST_DATETIME // ---------------------------------------------------------------------------- @@ -4353,39 +3818,6 @@ static void TestThreadConditions() wxThread::Sleep(500); } -#include "wx/utils.h" - -class MyExecThread : public wxThread -{ -public: - MyExecThread(const wxString& command) : wxThread(wxTHREAD_JOINABLE), - m_command(command) - { - Create(); - } - - virtual ExitCode Entry() - { - return (ExitCode)wxExecute(m_command, wxEXEC_SYNC); - } - -private: - wxString m_command; -}; - -static void TestThreadExec() -{ - wxPuts(_T("*** Testing wxExecute interaction with threads ***\n")); - - MyExecThread thread(_T("true")); - thread.Run(); - - wxPrintf(_T("Main program exit code: %ld.\n"), - wxExecute(_T("false"), wxEXEC_SYNC)); - - wxPrintf(_T("Thread exit code: %ld.\n"), (long)thread.Wait()); -} - // semaphore tests #include "wx/datetime.h" @@ -4461,6 +3893,24 @@ static void TestSemaphore() int main(int argc, char **argv) { +#if wxUSE_UNICODE + wxChar **wxArgv = new wxChar *[argc + 1]; + + { + int n; + + for (n = 0; n < argc; n++ ) + { + wxMB2WXbuf warg = wxConvertMB2WX(argv[n]); + wxArgv[n] = wxStrdup(warg); + } + + wxArgv[n] = NULL; + } +#else // !wxUSE_UNICODE + #define wxArgv argv +#endif // wxUSE_UNICODE/!wxUSE_UNICODE + wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); wxInitializer initializer; @@ -4498,52 +3948,27 @@ int main(int argc, char **argv) #if wxUSE_CMDLINE_PARSER static const wxCmdLineEntryDesc cmdLineDesc[] = { - { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"), + { wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, - { wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") }, - { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") }, + { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" }, + { wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" }, - { wxCMD_LINE_OPTION, _T("o"), _T("output"), _T("output file") }, - { wxCMD_LINE_OPTION, _T("i"), _T("input"), _T("input dir") }, - { wxCMD_LINE_OPTION, _T("s"), _T("size"), _T("output block size"), + { wxCMD_LINE_OPTION, "o", "output", "output file" }, + { wxCMD_LINE_OPTION, "i", "input", "input dir" }, + { wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER }, - { wxCMD_LINE_OPTION, _T("d"), _T("date"), _T("output file date"), + { wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_DATE }, + { wxCMD_LINE_OPTION, "f", "double", "output double", + wxCMD_LINE_VAL_DOUBLE }, - { wxCMD_LINE_PARAM, NULL, NULL, _T("input file"), + { wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE }, { wxCMD_LINE_NONE } }; -#if wxUSE_UNICODE - wxChar **wargv = new wxChar *[argc + 1]; - - { - int n; - - for (n = 0; n < argc; n++ ) - { - wxMB2WXbuf warg = wxConvertMB2WX(argv[n]); - wargv[n] = wxStrdup(warg); - } - - wargv[n] = NULL; - } - - #define argv wargv -#endif // wxUSE_UNICODE - - wxCmdLineParser parser(cmdLineDesc, argc, argv); - -#if wxUSE_UNICODE - { - for ( int n = 0; n < argc; n++ ) - free(wargv[n]); - - delete [] wargv; - } -#endif // wxUSE_UNICODE + wxCmdLineParser parser(cmdLineDesc, argc, wxArgv); parser.AddOption(_T("project_name"), _T(""), _T("full path to project file"), wxCMD_LINE_VAL_STRING, @@ -4575,27 +4000,19 @@ int main(int argc, char **argv) TestDirTraverse(); #endif // TEST_DIR -#ifdef TEST_DLLLOADER +#ifdef TEST_DYNLIB TestDllLoad(); -#endif // TEST_DLLLOADER + TestDllListLoaded(); +#endif // TEST_DYNLIB #ifdef TEST_ENVIRON TestEnvironment(); #endif // TEST_ENVIRON -#ifdef TEST_EXECUTE - TestExecute(); -#endif // TEST_EXECUTE - #ifdef TEST_FILECONF TestFileConfRead(); #endif // TEST_FILECONF -#ifdef TEST_LIST - TestListCtor(); - TestList(); -#endif // TEST_LIST - #ifdef TEST_LOCALE TestDefaultLang(); #endif // TEST_LOCALE @@ -4628,13 +4045,10 @@ int main(int argc, char **argv) TestFileRead(); TestTextFileRead(); TestFileCopy(); + TestTempFile(); #endif // TEST_FILE #ifdef TEST_FILENAME - TestFileNameConstruction(); - TestFileNameMakeRelative(); - TestFileNameMakeAbsolute(); - TestFileNameSplit(); TestFileNameTemp(); TestFileNameCwd(); TestFileNameDirManip(); @@ -4651,6 +4065,12 @@ int main(int argc, char **argv) #ifdef TEST_FTP wxLog::AddTraceMask(FTP_TRACE_MASK); + + // wxFTP cannot be a static variable as its ctor needs to access + // wxWidgets internals after it has been initialized + ftp = new wxFTP; + ftp->SetLog(new wxProtocolLog(FTP_TRACE_MASK)); + if ( TestFtpConnect() ) { #if TEST_ALL @@ -4659,45 +4079,34 @@ int main(int argc, char **argv) TestFtpMisc(); TestFtpFileSize(); TestFtpUpload(); - #endif + #endif // TEST_ALL #if TEST_INTERACTIVE - TestFtpInteractive(); + //TestFtpInteractive(); #endif } //else: connecting to the FTP server failed - #if 0 - TestFtpWuFtpd(); - #endif + delete ftp; #endif // TEST_FTP -#ifdef TEST_HASHMAP - TestHashMap(); -#endif // TEST_HASHMAP - -#ifdef TEST_HASHSET - TestHashSet(); -#endif // TEST_HASHSET - #ifdef TEST_MIME - wxLog::AddTraceMask(_T("mime")); - #if TEST_ALL - TestMimeEnum(); - TestMimeOverride(); - TestMimeAssociate(); - #endif + //wxLog::AddTraceMask(_T("mime")); + TestMimeEnum(); +#if 0 + TestMimeOverride(); + TestMimeAssociate(); +#endif TestMimeFilename(); #endif // TEST_MIME #ifdef TEST_INFO_FUNCTIONS - #if TEST_ALL - TestOsInfo(); - TestUserInfo(); + TestOsInfo(); + TestPlatformInfo(); + TestUserInfo(); - #if TEST_INTERACTIVE - TestDiskInfo(); - #endif + #if TEST_INTERACTIVE + TestDiskInfo(); #endif #endif // TEST_INFO_FUNCTIONS @@ -4705,10 +4114,6 @@ int main(int argc, char **argv) TestPathList(); #endif // TEST_PATHLIST -#ifdef TEST_ODBC - TestDbOpen(); -#endif // TEST_ODBC - #ifdef TEST_PRINTF TestPrintf(); #endif // TEST_PRINTF @@ -4759,28 +4164,21 @@ int main(int argc, char **argv) TestThreadSuspend(); TestThreadDelete(); TestThreadConditions(); - TestThreadExec(); TestSemaphore(); #endif #endif // TEST_THREADS #ifdef TEST_TIMER TestStopWatch(); + TestTimer(); #endif // TEST_TIMER #ifdef TEST_DATETIME #if TEST_ALL - TestTimeSet(); TestTimeStatic(); TestTimeRange(); TestTimeZones(); - TestTimeTicks(); - TestTimeJDN(); TestTimeDST(); - TestTimeWDays(); - TestTimeWNumber(); - TestTimeParse(); - TestTimeArithmetics(); TestTimeHolidays(); TestTimeSpanFormat(); TestTimeMS(); @@ -4797,16 +4195,21 @@ int main(int argc, char **argv) TestScopeGuard(); #endif +#ifdef TEST_STACKWALKER +#if wxUSE_STACKWALKER + TestStackWalk(argv[0]); +#endif +#endif // TEST_STACKWALKER + +#ifdef TEST_STDPATHS + TestStandardPaths(); +#endif + #ifdef TEST_USLEEP wxPuts(_T("Sleeping for 3 seconds... z-z-z-z-z...")); wxUsleep(3000); #endif // TEST_USLEEP -#ifdef TEST_VCARD - TestVCardRead(); - TestVCardWrite(); -#endif // TEST_VCARD - #ifdef TEST_VOLUME TestFSVolume(); #endif // TEST_VOLUME @@ -4821,8 +4224,16 @@ int main(int argc, char **argv) TestZipFileSystem(); #endif // TEST_ZIP +#if wxUSE_UNICODE + { + for ( int n = 0; n < argc; n++ ) + free(wxArgv[n]); + + delete [] wxArgv; + } +#endif // wxUSE_UNICODE + wxUnusedVar(argc); wxUnusedVar(argv); return 0; } -