1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/console/console.cpp
3 // Purpose: A sample console (as opposed to GUI) program using wxWidgets
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
24 #include "wx/string.h"
28 #include "wx/apptrait.h"
29 #include "wx/platinfo.h"
30 #include "wx/wxchar.h"
32 // without this pragma, the stupid compiler precompiles #defines below so that
33 // changing them doesn't "take place" later!
38 // ----------------------------------------------------------------------------
39 // conditional compilation
40 // ----------------------------------------------------------------------------
43 A note about all these conditional compilation macros: this file is used
44 both as a test suite for various non-GUI wxWidgets classes and as a
45 scratchpad for quick tests. So there are two compilation modes: if you
46 define TEST_ALL all tests are run, otherwise you may enable the individual
47 tests individually in the "#else" branch below.
50 // what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
51 // test, define it to 1 to do all tests.
66 // #define TEST_FTP --FIXME! (RN)
67 #define TEST_INFO_FUNCTIONS
78 #define TEST_SCOPEGUARD
80 // #define TEST_SOCKETS --FIXME! (RN)
81 #define TEST_STACKWALKER
84 #define TEST_TEXTSTREAM
87 // #define TEST_VCARD -- don't enable this (VZ)
88 // #define TEST_VOLUME --FIXME! (RN)
95 // some tests are interactive, define this to run them
96 #ifdef TEST_INTERACTIVE
97 #undef TEST_INTERACTIVE
99 #define TEST_INTERACTIVE 1
101 #define TEST_INTERACTIVE 0
104 // ============================================================================
106 // ============================================================================
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 #if defined(TEST_SOCKETS)
114 // replace TABs with \t and CRs with \n
115 static wxString
MakePrintable(const wxChar
*s
)
118 (void)str
.Replace(_T("\t"), _T("\\t"));
119 (void)str
.Replace(_T("\n"), _T("\\n"));
120 (void)str
.Replace(_T("\r"), _T("\\r"));
125 #endif // MakePrintable() is used
127 // ----------------------------------------------------------------------------
129 // ----------------------------------------------------------------------------
133 #include "wx/cmdline.h"
134 #include "wx/datetime.h"
136 #if wxUSE_CMDLINE_PARSER
138 static void ShowCmdLine(const wxCmdLineParser
& parser
)
140 wxString s
= _T("Command line parsed successfully:\nInput files: ");
142 size_t count
= parser
.GetParamCount();
143 for ( size_t param
= 0; param
< count
; param
++ )
145 s
<< parser
.GetParam(param
) << ' ';
149 << _T("Verbose:\t") << (parser
.Found(_T("v")) ? _T("yes") : _T("no")) << '\n'
150 << _T("Quiet:\t") << (parser
.Found(_T("q")) ? _T("yes") : _T("no")) << '\n';
155 if ( parser
.Found(_T("o"), &strVal
) )
156 s
<< _T("Output file:\t") << strVal
<< '\n';
157 if ( parser
.Found(_T("i"), &strVal
) )
158 s
<< _T("Input dir:\t") << strVal
<< '\n';
159 if ( parser
.Found(_T("s"), &lVal
) )
160 s
<< _T("Size:\t") << lVal
<< '\n';
161 if ( parser
.Found(_T("d"), &dt
) )
162 s
<< _T("Date:\t") << dt
.FormatISODate() << '\n';
163 if ( parser
.Found(_T("project_name"), &strVal
) )
164 s
<< _T("Project:\t") << strVal
<< '\n';
169 #endif // wxUSE_CMDLINE_PARSER
171 static void TestCmdLineConvert()
173 static const wxChar
*cmdlines
[] =
176 _T("-a \"-bstring 1\" -c\"string 2\" \"string 3\""),
177 _T("literal \\\" and \"\""),
180 for ( size_t n
= 0; n
< WXSIZEOF(cmdlines
); n
++ )
182 const wxChar
*cmdline
= cmdlines
[n
];
183 wxPrintf(_T("Parsing: %s\n"), cmdline
);
184 wxArrayString args
= wxCmdLineParser::ConvertStringToArgs(cmdline
);
186 size_t count
= args
.GetCount();
187 wxPrintf(_T("\targc = %u\n"), count
);
188 for ( size_t arg
= 0; arg
< count
; arg
++ )
190 wxPrintf(_T("\targv[%u] = %s\n"), arg
, args
[arg
].c_str());
195 #endif // TEST_CMDLINE
197 // ----------------------------------------------------------------------------
199 // ----------------------------------------------------------------------------
206 static const wxChar
*ROOTDIR
= _T("/");
207 static const wxChar
*TESTDIR
= _T("/usr/local/share");
208 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
209 static const wxChar
*ROOTDIR
= _T("c:\\");
210 static const wxChar
*TESTDIR
= _T("d:\\");
212 #error "don't know where the root directory is"
215 static void TestDirEnumHelper(wxDir
& dir
,
216 int flags
= wxDIR_DEFAULT
,
217 const wxString
& filespec
= wxEmptyString
)
221 if ( !dir
.IsOpened() )
224 bool cont
= dir
.GetFirst(&filename
, filespec
, flags
);
227 wxPrintf(_T("\t%s\n"), filename
.c_str());
229 cont
= dir
.GetNext(&filename
);
232 wxPuts(wxEmptyString
);
237 static void TestDirEnum()
239 wxPuts(_T("*** Testing wxDir::GetFirst/GetNext ***"));
241 wxString cwd
= wxGetCwd();
242 if ( !wxDir::Exists(cwd
) )
244 wxPrintf(_T("ERROR: current directory '%s' doesn't exist?\n"), cwd
.c_str());
249 if ( !dir
.IsOpened() )
251 wxPrintf(_T("ERROR: failed to open current directory '%s'.\n"), cwd
.c_str());
255 wxPuts(_T("Enumerating everything in current directory:"));
256 TestDirEnumHelper(dir
);
258 wxPuts(_T("Enumerating really everything in current directory:"));
259 TestDirEnumHelper(dir
, wxDIR_DEFAULT
| wxDIR_DOTDOT
);
261 wxPuts(_T("Enumerating object files in current directory:"));
262 TestDirEnumHelper(dir
, wxDIR_DEFAULT
, _T("*.o*"));
264 wxPuts(_T("Enumerating directories in current directory:"));
265 TestDirEnumHelper(dir
, wxDIR_DIRS
);
267 wxPuts(_T("Enumerating files in current directory:"));
268 TestDirEnumHelper(dir
, wxDIR_FILES
);
270 wxPuts(_T("Enumerating files including hidden in current directory:"));
271 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
275 wxPuts(_T("Enumerating everything in root directory:"));
276 TestDirEnumHelper(dir
, wxDIR_DEFAULT
);
278 wxPuts(_T("Enumerating directories in root directory:"));
279 TestDirEnumHelper(dir
, wxDIR_DIRS
);
281 wxPuts(_T("Enumerating files in root directory:"));
282 TestDirEnumHelper(dir
, wxDIR_FILES
);
284 wxPuts(_T("Enumerating files including hidden in root directory:"));
285 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
287 wxPuts(_T("Enumerating files in non existing directory:"));
288 wxDir
dirNo(_T("nosuchdir"));
289 TestDirEnumHelper(dirNo
);
294 class DirPrintTraverser
: public wxDirTraverser
297 virtual wxDirTraverseResult
OnFile(const wxString
& WXUNUSED(filename
))
299 return wxDIR_CONTINUE
;
302 virtual wxDirTraverseResult
OnDir(const wxString
& dirname
)
304 wxString path
, name
, ext
;
305 wxSplitPath(dirname
, &path
, &name
, &ext
);
308 name
<< _T('.') << ext
;
311 for ( const wxChar
*p
= path
.c_str(); *p
; p
++ )
313 if ( wxIsPathSeparator(*p
) )
317 wxPrintf(_T("%s%s\n"), indent
.c_str(), name
.c_str());
319 return wxDIR_CONTINUE
;
323 static void TestDirTraverse()
325 wxPuts(_T("*** Testing wxDir::Traverse() ***"));
329 size_t n
= wxDir::GetAllFiles(TESTDIR
, &files
);
330 wxPrintf(_T("There are %u files under '%s'\n"), n
, TESTDIR
);
333 wxPrintf(_T("First one is '%s'\n"), files
[0u].c_str());
334 wxPrintf(_T(" last one is '%s'\n"), files
[n
- 1].c_str());
337 // enum again with custom traverser
338 wxPuts(_T("Now enumerating directories:"));
340 DirPrintTraverser traverser
;
341 dir
.Traverse(traverser
, wxEmptyString
, wxDIR_DIRS
| wxDIR_HIDDEN
);
346 static void TestDirExists()
348 wxPuts(_T("*** Testing wxDir::Exists() ***"));
350 static const wxChar
*dirnames
[] =
353 #if defined(__WXMSW__)
356 _T("\\\\share\\file"),
360 _T("c:\\autoexec.bat"),
361 #elif defined(__UNIX__)
370 for ( size_t n
= 0; n
< WXSIZEOF(dirnames
); n
++ )
372 wxPrintf(_T("%-40s: %s\n"),
374 wxDir::Exists(dirnames
[n
]) ? _T("exists")
375 : _T("doesn't exist"));
383 // ----------------------------------------------------------------------------
385 // ----------------------------------------------------------------------------
389 #include "wx/dynlib.h"
391 static void TestDllLoad()
393 #if defined(__WXMSW__)
394 static const wxChar
*LIB_NAME
= _T("kernel32.dll");
395 static const wxChar
*FUNC_NAME
= _T("lstrlenA");
396 #elif defined(__UNIX__)
397 // weird: using just libc.so does *not* work!
398 static const wxChar
*LIB_NAME
= _T("/lib/libc.so.6");
399 static const wxChar
*FUNC_NAME
= _T("strlen");
401 #error "don't know how to test wxDllLoader on this platform"
404 wxPuts(_T("*** testing basic wxDynamicLibrary functions ***\n"));
406 wxDynamicLibrary
lib(LIB_NAME
);
407 if ( !lib
.IsLoaded() )
409 wxPrintf(_T("ERROR: failed to load '%s'.\n"), LIB_NAME
);
413 typedef int (wxSTDCALL
*wxStrlenType
)(const char *);
414 wxStrlenType pfnStrlen
= (wxStrlenType
)lib
.GetSymbol(FUNC_NAME
);
417 wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"),
418 FUNC_NAME
, LIB_NAME
);
422 wxPrintf(_T("Calling %s dynamically loaded from %s "),
423 FUNC_NAME
, LIB_NAME
);
425 if ( pfnStrlen("foo") != 3 )
427 wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n"));
431 wxPuts(_T("... ok"));
436 static const wxChar
*FUNC_NAME_AW
= _T("lstrlen");
438 typedef int (wxSTDCALL
*wxStrlenTypeAorW
)(const wxChar
*);
440 pfnStrlenAorW
= (wxStrlenTypeAorW
)lib
.GetSymbolAorW(FUNC_NAME_AW
);
441 if ( !pfnStrlenAorW
)
443 wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"),
444 FUNC_NAME_AW
, LIB_NAME
);
448 if ( pfnStrlenAorW(_T("foobar")) != 6 )
450 wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n"));
457 #if defined(__WXMSW__) || defined(__UNIX__)
459 static void TestDllListLoaded()
461 wxPuts(_T("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
463 puts("\nLoaded modules:");
464 wxDynamicLibraryDetailsArray dlls
= wxDynamicLibrary::ListLoaded();
465 const size_t count
= dlls
.GetCount();
466 for ( size_t n
= 0; n
< count
; ++n
)
468 const wxDynamicLibraryDetails
& details
= dlls
[n
];
469 printf("%-45s", details
.GetPath().mb_str());
473 if ( details
.GetAddress(&addr
, &len
) )
475 printf(" %08lx:%08lx",
476 (unsigned long)addr
, (unsigned long)((char *)addr
+ len
));
479 printf(" %s\n", details
.GetVersion().mb_str());
485 #endif // TEST_DYNLIB
487 // ----------------------------------------------------------------------------
489 // ----------------------------------------------------------------------------
493 #include "wx/utils.h"
495 static wxString
MyGetEnv(const wxString
& var
)
498 if ( !wxGetEnv(var
, &val
) )
501 val
= wxString(_T('\'')) + val
+ _T('\'');
506 static void TestEnvironment()
508 const wxChar
*var
= _T("wxTestVar");
510 wxPuts(_T("*** testing environment access functions ***"));
512 wxPrintf(_T("Initially getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
513 wxSetEnv(var
, _T("value for wxTestVar"));
514 wxPrintf(_T("After wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
515 wxSetEnv(var
, _T("another value"));
516 wxPrintf(_T("After 2nd wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
518 wxPrintf(_T("After wxUnsetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
519 wxPrintf(_T("PATH = %s\n"), MyGetEnv(_T("PATH")).c_str());
522 #endif // TEST_ENVIRON
524 // ----------------------------------------------------------------------------
526 // ----------------------------------------------------------------------------
530 #include "wx/utils.h"
532 static void TestExecute()
534 wxPuts(_T("*** testing wxExecute ***"));
537 #define COMMAND "cat -n ../../Makefile" // "echo hi"
538 #define SHELL_COMMAND "echo hi from shell"
539 #define REDIRECT_COMMAND COMMAND // "date"
540 #elif defined(__WXMSW__)
541 #define COMMAND "command.com /c echo hi"
542 #define SHELL_COMMAND "echo hi"
543 #define REDIRECT_COMMAND COMMAND
545 #error "no command to exec"
548 wxPrintf(_T("Testing wxShell: "));
550 if ( wxShell(_T(SHELL_COMMAND
)) )
553 wxPuts(_T("ERROR."));
555 wxPrintf(_T("Testing wxExecute: "));
557 if ( wxExecute(_T(COMMAND
), true /* sync */) == 0 )
560 wxPuts(_T("ERROR."));
562 #if 0 // no, it doesn't work (yet?)
563 wxPrintf(_T("Testing async wxExecute: "));
565 if ( wxExecute(COMMAND
) != 0 )
566 wxPuts(_T("Ok (command launched)."));
568 wxPuts(_T("ERROR."));
571 wxPrintf(_T("Testing wxExecute with redirection:\n"));
572 wxArrayString output
;
573 if ( wxExecute(_T(REDIRECT_COMMAND
), output
) != 0 )
575 wxPuts(_T("ERROR."));
579 size_t count
= output
.GetCount();
580 for ( size_t n
= 0; n
< count
; n
++ )
582 wxPrintf(_T("\t%s\n"), output
[n
].c_str());
589 #endif // TEST_EXECUTE
591 // ----------------------------------------------------------------------------
593 // ----------------------------------------------------------------------------
598 #include "wx/ffile.h"
599 #include "wx/textfile.h"
601 static void TestFileRead()
603 wxPuts(_T("*** wxFile read test ***"));
605 wxFile
file(_T("testdata.fc"));
606 if ( file
.IsOpened() )
608 wxPrintf(_T("File length: %lu\n"), file
.Length());
610 wxPuts(_T("File dump:\n----------"));
612 static const size_t len
= 1024;
616 size_t nRead
= file
.Read(buf
, len
);
617 if ( nRead
== (size_t)wxInvalidOffset
)
619 wxPrintf(_T("Failed to read the file."));
623 fwrite(buf
, nRead
, 1, stdout
);
629 wxPuts(_T("----------"));
633 wxPrintf(_T("ERROR: can't open test file.\n"));
636 wxPuts(wxEmptyString
);
639 static void TestTextFileRead()
641 wxPuts(_T("*** wxTextFile read test ***"));
643 wxTextFile
file(_T("testdata.fc"));
646 wxPrintf(_T("Number of lines: %u\n"), file
.GetLineCount());
647 wxPrintf(_T("Last line: '%s'\n"), file
.GetLastLine().c_str());
651 wxPuts(_T("\nDumping the entire file:"));
652 for ( s
= file
.GetFirstLine(); !file
.Eof(); s
= file
.GetNextLine() )
654 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
656 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
658 wxPuts(_T("\nAnd now backwards:"));
659 for ( s
= file
.GetLastLine();
660 file
.GetCurrentLine() != 0;
661 s
= file
.GetPrevLine() )
663 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
665 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
669 wxPrintf(_T("ERROR: can't open '%s'\n"), file
.GetName());
672 wxPuts(wxEmptyString
);
675 static void TestFileCopy()
677 wxPuts(_T("*** Testing wxCopyFile ***"));
679 static const wxChar
*filename1
= _T("testdata.fc");
680 static const wxChar
*filename2
= _T("test2");
681 if ( !wxCopyFile(filename1
, filename2
) )
683 wxPuts(_T("ERROR: failed to copy file"));
687 wxFFile
f1(filename1
, _T("rb")),
688 f2(filename2
, _T("rb"));
690 if ( !f1
.IsOpened() || !f2
.IsOpened() )
692 wxPuts(_T("ERROR: failed to open file(s)"));
697 if ( !f1
.ReadAll(&s1
) || !f2
.ReadAll(&s2
) )
699 wxPuts(_T("ERROR: failed to read file(s)"));
703 if ( (s1
.length() != s2
.length()) ||
704 (memcmp(s1
.c_str(), s2
.c_str(), s1
.length()) != 0) )
706 wxPuts(_T("ERROR: copy error!"));
710 wxPuts(_T("File was copied ok."));
716 if ( !wxRemoveFile(filename2
) )
718 wxPuts(_T("ERROR: failed to remove the file"));
721 wxPuts(wxEmptyString
);
724 static void TestTempFile()
726 wxPuts(_T("*** wxTempFile test ***"));
729 if ( tmpFile
.Open(_T("test2")) && tmpFile
.Write(_T("the answer is 42")) )
731 if ( tmpFile
.Commit() )
732 wxPuts(_T("File committed."));
734 wxPuts(_T("ERROR: could't commit temp file."));
736 wxRemoveFile(_T("test2"));
739 wxPuts(wxEmptyString
);
744 // ----------------------------------------------------------------------------
746 // ----------------------------------------------------------------------------
750 #include "wx/confbase.h"
751 #include "wx/fileconf.h"
753 static const struct FileConfTestData
755 const wxChar
*name
; // value name
756 const wxChar
*value
; // the value from the file
759 { _T("value1"), _T("one") },
760 { _T("value2"), _T("two") },
761 { _T("novalue"), _T("default") },
764 static void TestFileConfRead()
766 wxPuts(_T("*** testing wxFileConfig loading/reading ***"));
768 wxFileConfig
fileconf(_T("test"), wxEmptyString
,
769 _T("testdata.fc"), wxEmptyString
,
770 wxCONFIG_USE_RELATIVE_PATH
);
772 // test simple reading
773 wxPuts(_T("\nReading config file:"));
774 wxString
defValue(_T("default")), value
;
775 for ( size_t n
= 0; n
< WXSIZEOF(fcTestData
); n
++ )
777 const FileConfTestData
& data
= fcTestData
[n
];
778 value
= fileconf
.Read(data
.name
, defValue
);
779 wxPrintf(_T("\t%s = %s "), data
.name
, value
.c_str());
780 if ( value
== data
.value
)
786 wxPrintf(_T("(ERROR: should be %s)\n"), data
.value
);
790 // test enumerating the entries
791 wxPuts(_T("\nEnumerating all root entries:"));
794 bool cont
= fileconf
.GetFirstEntry(name
, dummy
);
797 wxPrintf(_T("\t%s = %s\n"),
799 fileconf
.Read(name
.c_str(), _T("ERROR")).c_str());
801 cont
= fileconf
.GetNextEntry(name
, dummy
);
804 static const wxChar
*testEntry
= _T("TestEntry");
805 wxPrintf(_T("\nTesting deletion of newly created \"Test\" entry: "));
806 fileconf
.Write(testEntry
, _T("A value"));
807 fileconf
.DeleteEntry(testEntry
);
808 wxPrintf(fileconf
.HasEntry(testEntry
) ? _T("ERROR\n") : _T("ok\n"));
811 #endif // TEST_FILECONF
813 // ----------------------------------------------------------------------------
815 // ----------------------------------------------------------------------------
819 #include "wx/filename.h"
822 static void DumpFileName(const wxChar
*desc
, const wxFileName
& fn
)
826 wxString full
= fn
.GetFullPath();
828 wxString vol
, path
, name
, ext
;
829 wxFileName::SplitPath(full
, &vol
, &path
, &name
, &ext
);
831 wxPrintf(_T("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
832 full
.c_str(), vol
.c_str(), path
.c_str(), name
.c_str(), ext
.c_str());
834 wxFileName::SplitPath(full
, &path
, &name
, &ext
);
835 wxPrintf(_T("or\t\t-> path '%s', name '%s', ext '%s'\n"),
836 path
.c_str(), name
.c_str(), ext
.c_str());
838 wxPrintf(_T("path is also:\t'%s'\n"), fn
.GetPath().c_str());
839 wxPrintf(_T("with volume: \t'%s'\n"),
840 fn
.GetPath(wxPATH_GET_VOLUME
).c_str());
841 wxPrintf(_T("with separator:\t'%s'\n"),
842 fn
.GetPath(wxPATH_GET_SEPARATOR
).c_str());
843 wxPrintf(_T("with both: \t'%s'\n"),
844 fn
.GetPath(wxPATH_GET_SEPARATOR
| wxPATH_GET_VOLUME
).c_str());
846 wxPuts(_T("The directories in the path are:"));
847 wxArrayString dirs
= fn
.GetDirs();
848 size_t count
= dirs
.GetCount();
849 for ( size_t n
= 0; n
< count
; n
++ )
851 wxPrintf(_T("\t%u: %s\n"), n
, dirs
[n
].c_str());
856 static void TestFileNameTemp()
858 wxPuts(_T("*** testing wxFileName temp file creation ***"));
860 static const wxChar
*tmpprefixes
[] =
868 _T("/tmp/foo/bar"), // this one must be an error
872 for ( size_t n
= 0; n
< WXSIZEOF(tmpprefixes
); n
++ )
874 wxString path
= wxFileName::CreateTempFileName(tmpprefixes
[n
]);
877 // "error" is not in upper case because it may be ok
878 wxPrintf(_T("Prefix '%s'\t-> error\n"), tmpprefixes
[n
]);
882 wxPrintf(_T("Prefix '%s'\t-> temp file '%s'\n"),
883 tmpprefixes
[n
], path
.c_str());
885 if ( !wxRemoveFile(path
) )
887 wxLogWarning(_T("Failed to remove temp file '%s'"),
894 static void TestFileNameDirManip()
896 // TODO: test AppendDir(), RemoveDir(), ...
899 static void TestFileNameComparison()
904 static void TestFileNameOperations()
909 static void TestFileNameCwd()
914 #endif // TEST_FILENAME
916 // ----------------------------------------------------------------------------
917 // wxFileName time functions
918 // ----------------------------------------------------------------------------
922 #include "wx/filename.h"
923 #include "wx/datetime.h"
925 static void TestFileGetTimes()
927 wxFileName
fn(_T("testdata.fc"));
929 wxDateTime dtAccess
, dtMod
, dtCreate
;
930 if ( !fn
.GetTimes(&dtAccess
, &dtMod
, &dtCreate
) )
932 wxPrintf(_T("ERROR: GetTimes() failed.\n"));
936 static const wxChar
*fmt
= _T("%Y-%b-%d %H:%M:%S");
938 wxPrintf(_T("File times for '%s':\n"), fn
.GetFullPath().c_str());
939 wxPrintf(_T("Creation: \t%s\n"), dtCreate
.Format(fmt
).c_str());
940 wxPrintf(_T("Last read: \t%s\n"), dtAccess
.Format(fmt
).c_str());
941 wxPrintf(_T("Last write: \t%s\n"), dtMod
.Format(fmt
).c_str());
946 static void TestFileSetTimes()
948 wxFileName
fn(_T("testdata.fc"));
952 wxPrintf(_T("ERROR: Touch() failed.\n"));
957 #endif // TEST_FILETIME
959 // ----------------------------------------------------------------------------
961 // ----------------------------------------------------------------------------
966 #include "wx/utils.h" // for wxSetEnv
968 static wxLocale
gs_localeDefault(wxLANGUAGE_ENGLISH
);
970 // find the name of the language from its value
971 static const wxChar
*GetLangName(int lang
)
973 static const wxChar
*languageNames
[] =
983 _T("ARABIC_ALGERIA"),
984 _T("ARABIC_BAHRAIN"),
989 _T("ARABIC_LEBANON"),
991 _T("ARABIC_MOROCCO"),
994 _T("ARABIC_SAUDI_ARABIA"),
997 _T("ARABIC_TUNISIA"),
1004 _T("AZERI_CYRILLIC"),
1019 _T("CHINESE_SIMPLIFIED"),
1020 _T("CHINESE_TRADITIONAL"),
1021 _T("CHINESE_HONGKONG"),
1022 _T("CHINESE_MACAU"),
1023 _T("CHINESE_SINGAPORE"),
1024 _T("CHINESE_TAIWAN"),
1030 _T("DUTCH_BELGIAN"),
1034 _T("ENGLISH_AUSTRALIA"),
1035 _T("ENGLISH_BELIZE"),
1036 _T("ENGLISH_BOTSWANA"),
1037 _T("ENGLISH_CANADA"),
1038 _T("ENGLISH_CARIBBEAN"),
1039 _T("ENGLISH_DENMARK"),
1041 _T("ENGLISH_JAMAICA"),
1042 _T("ENGLISH_NEW_ZEALAND"),
1043 _T("ENGLISH_PHILIPPINES"),
1044 _T("ENGLISH_SOUTH_AFRICA"),
1045 _T("ENGLISH_TRINIDAD"),
1046 _T("ENGLISH_ZIMBABWE"),
1054 _T("FRENCH_BELGIAN"),
1055 _T("FRENCH_CANADIAN"),
1056 _T("FRENCH_LUXEMBOURG"),
1057 _T("FRENCH_MONACO"),
1063 _T("GERMAN_AUSTRIAN"),
1064 _T("GERMAN_BELGIUM"),
1065 _T("GERMAN_LIECHTENSTEIN"),
1066 _T("GERMAN_LUXEMBOURG"),
1084 _T("ITALIAN_SWISS"),
1089 _T("KASHMIRI_INDIA"),
1107 _T("MALAY_BRUNEI_DARUSSALAM"),
1108 _T("MALAY_MALAYSIA"),
1118 _T("NORWEGIAN_BOKMAL"),
1119 _T("NORWEGIAN_NYNORSK"),
1126 _T("PORTUGUESE_BRAZILIAN"),
1129 _T("RHAETO_ROMANCE"),
1132 _T("RUSSIAN_UKRAINE"),
1138 _T("SERBIAN_CYRILLIC"),
1139 _T("SERBIAN_LATIN"),
1140 _T("SERBO_CROATIAN"),
1151 _T("SPANISH_ARGENTINA"),
1152 _T("SPANISH_BOLIVIA"),
1153 _T("SPANISH_CHILE"),
1154 _T("SPANISH_COLOMBIA"),
1155 _T("SPANISH_COSTA_RICA"),
1156 _T("SPANISH_DOMINICAN_REPUBLIC"),
1157 _T("SPANISH_ECUADOR"),
1158 _T("SPANISH_EL_SALVADOR"),
1159 _T("SPANISH_GUATEMALA"),
1160 _T("SPANISH_HONDURAS"),
1161 _T("SPANISH_MEXICAN"),
1162 _T("SPANISH_MODERN"),
1163 _T("SPANISH_NICARAGUA"),
1164 _T("SPANISH_PANAMA"),
1165 _T("SPANISH_PARAGUAY"),
1167 _T("SPANISH_PUERTO_RICO"),
1168 _T("SPANISH_URUGUAY"),
1170 _T("SPANISH_VENEZUELA"),
1174 _T("SWEDISH_FINLAND"),
1192 _T("URDU_PAKISTAN"),
1194 _T("UZBEK_CYRILLIC"),
1207 if ( (size_t)lang
< WXSIZEOF(languageNames
) )
1208 return languageNames
[lang
];
1210 return _T("INVALID");
1213 static void TestDefaultLang()
1215 wxPuts(_T("*** Testing wxLocale::GetSystemLanguage ***"));
1217 static const wxChar
*langStrings
[] =
1219 NULL
, // system default
1226 _T("de_DE.iso88591"),
1228 _T("?"), // invalid lang spec
1229 _T("klingonese"), // I bet on some systems it does exist...
1232 wxPrintf(_T("The default system encoding is %s (%d)\n"),
1233 wxLocale::GetSystemEncodingName().c_str(),
1234 wxLocale::GetSystemEncoding());
1236 for ( size_t n
= 0; n
< WXSIZEOF(langStrings
); n
++ )
1238 const wxChar
*langStr
= langStrings
[n
];
1241 // FIXME: this doesn't do anything at all under Windows, we need
1242 // to create a new wxLocale!
1243 wxSetEnv(_T("LC_ALL"), langStr
);
1246 int lang
= gs_localeDefault
.GetSystemLanguage();
1247 wxPrintf(_T("Locale for '%s' is %s.\n"),
1248 langStr
? langStr
: _T("system default"), GetLangName(lang
));
1252 #endif // TEST_LOCALE
1254 // ----------------------------------------------------------------------------
1256 // ----------------------------------------------------------------------------
1260 #include "wx/mimetype.h"
1262 static void TestMimeEnum()
1264 wxPuts(_T("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1266 wxArrayString mimetypes
;
1268 size_t count
= wxTheMimeTypesManager
->EnumAllFileTypes(mimetypes
);
1270 wxPrintf(_T("*** All %u known filetypes: ***\n"), count
);
1275 for ( size_t n
= 0; n
< count
; n
++ )
1277 wxFileType
*filetype
=
1278 wxTheMimeTypesManager
->GetFileTypeFromMimeType(mimetypes
[n
]);
1281 wxPrintf(_T("nothing known about the filetype '%s'!\n"),
1282 mimetypes
[n
].c_str());
1286 filetype
->GetDescription(&desc
);
1287 filetype
->GetExtensions(exts
);
1289 filetype
->GetIcon(NULL
);
1292 for ( size_t e
= 0; e
< exts
.GetCount(); e
++ )
1295 extsAll
<< _T(", ");
1299 wxPrintf(_T("\t%s: %s (%s)\n"),
1300 mimetypes
[n
].c_str(), desc
.c_str(), extsAll
.c_str());
1303 wxPuts(wxEmptyString
);
1306 static void TestMimeOverride()
1308 wxPuts(_T("*** Testing wxMimeTypesManager additional files loading ***\n"));
1310 static const wxChar
*mailcap
= _T("/tmp/mailcap");
1311 static const wxChar
*mimetypes
= _T("/tmp/mime.types");
1313 if ( wxFile::Exists(mailcap
) )
1314 wxPrintf(_T("Loading mailcap from '%s': %s\n"),
1316 wxTheMimeTypesManager
->ReadMailcap(mailcap
) ? _T("ok") : _T("ERROR"));
1318 wxPrintf(_T("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1321 if ( wxFile::Exists(mimetypes
) )
1322 wxPrintf(_T("Loading mime.types from '%s': %s\n"),
1324 wxTheMimeTypesManager
->ReadMimeTypes(mimetypes
) ? _T("ok") : _T("ERROR"));
1326 wxPrintf(_T("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1329 wxPuts(wxEmptyString
);
1332 static void TestMimeFilename()
1334 wxPuts(_T("*** Testing MIME type from filename query ***\n"));
1336 static const wxChar
*filenames
[] =
1344 for ( size_t n
= 0; n
< WXSIZEOF(filenames
); n
++ )
1346 const wxString fname
= filenames
[n
];
1347 wxString ext
= fname
.AfterLast(_T('.'));
1348 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
1351 wxPrintf(_T("WARNING: extension '%s' is unknown.\n"), ext
.c_str());
1356 if ( !ft
->GetDescription(&desc
) )
1357 desc
= _T("<no description>");
1360 if ( !ft
->GetOpenCommand(&cmd
,
1361 wxFileType::MessageParameters(fname
, wxEmptyString
)) )
1362 cmd
= _T("<no command available>");
1364 cmd
= wxString(_T('"')) + cmd
+ _T('"');
1366 wxPrintf(_T("To open %s (%s) do %s.\n"),
1367 fname
.c_str(), desc
.c_str(), cmd
.c_str());
1373 wxPuts(wxEmptyString
);
1376 static void TestMimeAssociate()
1378 wxPuts(_T("*** Testing creation of filetype association ***\n"));
1380 wxFileTypeInfo
ftInfo(
1381 _T("application/x-xyz"),
1382 _T("xyzview '%s'"), // open cmd
1383 _T(""), // print cmd
1384 _T("XYZ File"), // description
1385 _T(".xyz"), // extensions
1386 NULL
// end of extensions
1388 ftInfo
.SetShortDesc(_T("XYZFile")); // used under Win32 only
1390 wxFileType
*ft
= wxTheMimeTypesManager
->Associate(ftInfo
);
1393 wxPuts(_T("ERROR: failed to create association!"));
1397 // TODO: read it back
1401 wxPuts(wxEmptyString
);
1406 // ----------------------------------------------------------------------------
1407 // module dependencies feature
1408 // ----------------------------------------------------------------------------
1412 #include "wx/module.h"
1414 class wxTestModule
: public wxModule
1417 virtual bool OnInit() { wxPrintf(_T("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1418 virtual void OnExit() { wxPrintf(_T("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1421 class wxTestModuleA
: public wxTestModule
1426 DECLARE_DYNAMIC_CLASS(wxTestModuleA
)
1429 class wxTestModuleB
: public wxTestModule
1434 DECLARE_DYNAMIC_CLASS(wxTestModuleB
)
1437 class wxTestModuleC
: public wxTestModule
1442 DECLARE_DYNAMIC_CLASS(wxTestModuleC
)
1445 class wxTestModuleD
: public wxTestModule
1450 DECLARE_DYNAMIC_CLASS(wxTestModuleD
)
1453 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC
, wxModule
)
1454 wxTestModuleC::wxTestModuleC()
1456 AddDependency(CLASSINFO(wxTestModuleD
));
1459 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA
, wxModule
)
1460 wxTestModuleA::wxTestModuleA()
1462 AddDependency(CLASSINFO(wxTestModuleB
));
1463 AddDependency(CLASSINFO(wxTestModuleD
));
1466 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD
, wxModule
)
1467 wxTestModuleD::wxTestModuleD()
1471 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB
, wxModule
)
1472 wxTestModuleB::wxTestModuleB()
1474 AddDependency(CLASSINFO(wxTestModuleD
));
1475 AddDependency(CLASSINFO(wxTestModuleC
));
1478 #endif // TEST_MODULE
1480 // ----------------------------------------------------------------------------
1481 // misc information functions
1482 // ----------------------------------------------------------------------------
1484 #ifdef TEST_INFO_FUNCTIONS
1486 #include "wx/utils.h"
1488 #if TEST_INTERACTIVE
1489 static void TestDiskInfo()
1491 wxPuts(_T("*** Testing wxGetDiskSpace() ***"));
1495 wxChar pathname
[128];
1496 wxPrintf(_T("\nEnter a directory name: "));
1497 if ( !wxFgets(pathname
, WXSIZEOF(pathname
), stdin
) )
1500 // kill the last '\n'
1501 pathname
[wxStrlen(pathname
) - 1] = 0;
1503 wxLongLong total
, free
;
1504 if ( !wxGetDiskSpace(pathname
, &total
, &free
) )
1506 wxPuts(_T("ERROR: wxGetDiskSpace failed."));
1510 wxPrintf(_T("%sKb total, %sKb free on '%s'.\n"),
1511 (total
/ 1024).ToString().c_str(),
1512 (free
/ 1024).ToString().c_str(),
1517 #endif // TEST_INTERACTIVE
1519 static void TestOsInfo()
1521 wxPuts(_T("*** Testing OS info functions ***\n"));
1524 wxGetOsVersion(&major
, &minor
);
1525 wxPrintf(_T("Running under: %s, version %d.%d\n"),
1526 wxGetOsDescription().c_str(), major
, minor
);
1528 wxPrintf(_T("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1530 wxPrintf(_T("Host name is %s (%s).\n"),
1531 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1533 wxPuts(wxEmptyString
);
1536 static void TestPlatformInfo()
1538 wxPuts(_T("*** Testing wxPlatformInfo functions ***\n"));
1540 // get this platform
1541 wxPlatformInfo plat
;
1543 wxPrintf(_T("Operating system family name is: %s\n"), plat
.GetOperatingSystemFamilyName().c_str());
1544 wxPrintf(_T("Operating system name is: %s\n"), plat
.GetOperatingSystemIdName().c_str());
1545 wxPrintf(_T("Port ID name is: %s\n"), plat
.GetPortIdName().c_str());
1546 wxPrintf(_T("Port ID short name is: %s\n"), plat
.GetPortIdShortName().c_str());
1547 wxPrintf(_T("Architecture is: %s\n"), plat
.GetArchName().c_str());
1548 wxPrintf(_T("Endianness is: %s\n"), plat
.GetEndiannessName().c_str());
1550 wxPuts(wxEmptyString
);
1553 static void TestUserInfo()
1555 wxPuts(_T("*** Testing user info functions ***\n"));
1557 wxPrintf(_T("User id is:\t%s\n"), wxGetUserId().c_str());
1558 wxPrintf(_T("User name is:\t%s\n"), wxGetUserName().c_str());
1559 wxPrintf(_T("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1560 wxPrintf(_T("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1562 wxPuts(wxEmptyString
);
1565 #endif // TEST_INFO_FUNCTIONS
1567 // ----------------------------------------------------------------------------
1569 // ----------------------------------------------------------------------------
1571 #ifdef TEST_PATHLIST
1574 #define CMD_IN_PATH _T("ls")
1576 #define CMD_IN_PATH _T("command.com")
1579 static void TestPathList()
1581 wxPuts(_T("*** Testing wxPathList ***\n"));
1583 wxPathList pathlist
;
1584 pathlist
.AddEnvList(_T("PATH"));
1585 wxString path
= pathlist
.FindValidPath(CMD_IN_PATH
);
1588 wxPrintf(_T("ERROR: command not found in the path.\n"));
1592 wxPrintf(_T("Command found in the path as '%s'.\n"), path
.c_str());
1596 #endif // TEST_PATHLIST
1598 // ----------------------------------------------------------------------------
1599 // regular expressions
1600 // ----------------------------------------------------------------------------
1604 #include "wx/regex.h"
1606 static void TestRegExInteractive()
1608 wxPuts(_T("*** Testing RE interactively ***"));
1612 wxChar pattern
[128];
1613 wxPrintf(_T("\nEnter a pattern: "));
1614 if ( !wxFgets(pattern
, WXSIZEOF(pattern
), stdin
) )
1617 // kill the last '\n'
1618 pattern
[wxStrlen(pattern
) - 1] = 0;
1621 if ( !re
.Compile(pattern
) )
1629 wxPrintf(_T("Enter text to match: "));
1630 if ( !wxFgets(text
, WXSIZEOF(text
), stdin
) )
1633 // kill the last '\n'
1634 text
[wxStrlen(text
) - 1] = 0;
1636 if ( !re
.Matches(text
) )
1638 wxPrintf(_T("No match.\n"));
1642 wxPrintf(_T("Pattern matches at '%s'\n"), re
.GetMatch(text
).c_str());
1645 for ( size_t n
= 1; ; n
++ )
1647 if ( !re
.GetMatch(&start
, &len
, n
) )
1652 wxPrintf(_T("Subexpr %u matched '%s'\n"),
1653 n
, wxString(text
+ start
, len
).c_str());
1660 #endif // TEST_REGEX
1662 // ----------------------------------------------------------------------------
1664 // ----------------------------------------------------------------------------
1674 static void TestDbOpen()
1682 // ----------------------------------------------------------------------------
1684 // ----------------------------------------------------------------------------
1687 NB: this stuff was taken from the glibc test suite and modified to build
1688 in wxWidgets: if I read the copyright below properly, this shouldn't
1694 #ifdef wxTEST_PRINTF
1695 // use our functions from wxchar.cpp
1699 // NB: do _not_ use ATTRIBUTE_PRINTF here, we have some invalid formats
1700 // in the tests below
1701 int wxPrintf( const wxChar
*format
, ... );
1702 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... );
1705 #include "wx/longlong.h"
1709 static void rfg1 (void);
1710 static void rfg2 (void);
1714 fmtchk (const wxChar
*fmt
)
1716 (void) wxPrintf(_T("%s:\t`"), fmt
);
1717 (void) wxPrintf(fmt
, 0x12);
1718 (void) wxPrintf(_T("'\n"));
1722 fmtst1chk (const wxChar
*fmt
)
1724 (void) wxPrintf(_T("%s:\t`"), fmt
);
1725 (void) wxPrintf(fmt
, 4, 0x12);
1726 (void) wxPrintf(_T("'\n"));
1730 fmtst2chk (const wxChar
*fmt
)
1732 (void) wxPrintf(_T("%s:\t`"), fmt
);
1733 (void) wxPrintf(fmt
, 4, 4, 0x12);
1734 (void) wxPrintf(_T("'\n"));
1737 /* This page is covered by the following copyright: */
1739 /* (C) Copyright C E Chew
1741 * Feel free to copy, use and distribute this software provided:
1743 * 1. you do not pretend that you wrote it
1744 * 2. you leave this copyright notice intact.
1748 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1755 /* Formatted Output Test
1757 * This exercises the output formatting code.
1760 wxChar
*PointerNull
= NULL
;
1767 wxChar
*prefix
= buf
;
1770 wxPuts(_T("\nFormatted output test"));
1771 wxPrintf(_T("prefix 6d 6o 6x 6X 6u\n"));
1772 wxStrcpy(prefix
, _T("%"));
1773 for (i
= 0; i
< 2; i
++) {
1774 for (j
= 0; j
< 2; j
++) {
1775 for (k
= 0; k
< 2; k
++) {
1776 for (l
= 0; l
< 2; l
++) {
1777 wxStrcpy(prefix
, _T("%"));
1778 if (i
== 0) wxStrcat(prefix
, _T("-"));
1779 if (j
== 0) wxStrcat(prefix
, _T("+"));
1780 if (k
== 0) wxStrcat(prefix
, _T("#"));
1781 if (l
== 0) wxStrcat(prefix
, _T("0"));
1782 wxPrintf(_T("%5s |"), prefix
);
1783 wxStrcpy(tp
, prefix
);
1784 wxStrcat(tp
, _T("6d |"));
1786 wxStrcpy(tp
, prefix
);
1787 wxStrcat(tp
, _T("6o |"));
1789 wxStrcpy(tp
, prefix
);
1790 wxStrcat(tp
, _T("6x |"));
1792 wxStrcpy(tp
, prefix
);
1793 wxStrcat(tp
, _T("6X |"));
1795 wxStrcpy(tp
, prefix
);
1796 wxStrcat(tp
, _T("6u |"));
1803 wxPrintf(_T("%10s\n"), PointerNull
);
1804 wxPrintf(_T("%-10s\n"), PointerNull
);
1807 static void TestPrintf()
1809 static wxChar shortstr
[] = _T("Hi, Z.");
1810 static wxChar longstr
[] = _T("Good morning, Doctor Chandra. This is Hal. \
1811 I am ready for my first lesson today.");
1813 wxString test_format
;
1817 fmtchk(_T("%4.4x"));
1818 fmtchk(_T("%04.4x"));
1819 fmtchk(_T("%4.3x"));
1820 fmtchk(_T("%04.3x"));
1822 fmtst1chk(_T("%.*x"));
1823 fmtst1chk(_T("%0*x"));
1824 fmtst2chk(_T("%*.*x"));
1825 fmtst2chk(_T("%0*.*x"));
1827 wxString bad_format
= _T("bad format:\t\"%b\"\n");
1828 wxPrintf(bad_format
.c_str());
1829 wxPrintf(_T("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL
);
1831 wxPrintf(_T("decimal negative:\t\"%d\"\n"), -2345);
1832 wxPrintf(_T("octal negative:\t\"%o\"\n"), -2345);
1833 wxPrintf(_T("hex negative:\t\"%x\"\n"), -2345);
1834 wxPrintf(_T("long decimal number:\t\"%ld\"\n"), -123456L);
1835 wxPrintf(_T("long octal negative:\t\"%lo\"\n"), -2345L);
1836 wxPrintf(_T("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
1837 wxPrintf(_T("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
1838 test_format
= _T("left-adjusted ZLDN:\t\"%-010ld\"\n");
1839 wxPrintf(test_format
.c_str(), -123456);
1840 wxPrintf(_T("space-padded LDN:\t\"%10ld\"\n"), -123456L);
1841 wxPrintf(_T("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
1843 test_format
= _T("zero-padded string:\t\"%010s\"\n");
1844 wxPrintf(test_format
.c_str(), shortstr
);
1845 test_format
= _T("left-adjusted Z string:\t\"%-010s\"\n");
1846 wxPrintf(test_format
.c_str(), shortstr
);
1847 wxPrintf(_T("space-padded string:\t\"%10s\"\n"), shortstr
);
1848 wxPrintf(_T("left-adjusted S string:\t\"%-10s\"\n"), shortstr
);
1849 wxPrintf(_T("null string:\t\"%s\"\n"), PointerNull
);
1850 wxPrintf(_T("limited string:\t\"%.22s\"\n"), longstr
);
1852 wxPrintf(_T("e-style >= 1:\t\"%e\"\n"), 12.34);
1853 wxPrintf(_T("e-style >= .1:\t\"%e\"\n"), 0.1234);
1854 wxPrintf(_T("e-style < .1:\t\"%e\"\n"), 0.001234);
1855 wxPrintf(_T("e-style big:\t\"%.60e\"\n"), 1e20
);
1856 wxPrintf(_T("e-style == .1:\t\"%e\"\n"), 0.1);
1857 wxPrintf(_T("f-style >= 1:\t\"%f\"\n"), 12.34);
1858 wxPrintf(_T("f-style >= .1:\t\"%f\"\n"), 0.1234);
1859 wxPrintf(_T("f-style < .1:\t\"%f\"\n"), 0.001234);
1860 wxPrintf(_T("g-style >= 1:\t\"%g\"\n"), 12.34);
1861 wxPrintf(_T("g-style >= .1:\t\"%g\"\n"), 0.1234);
1862 wxPrintf(_T("g-style < .1:\t\"%g\"\n"), 0.001234);
1863 wxPrintf(_T("g-style big:\t\"%.60g\"\n"), 1e20
);
1865 wxPrintf (_T(" %6.5f\n"), .099999999860301614);
1866 wxPrintf (_T(" %6.5f\n"), .1);
1867 wxPrintf (_T("x%5.4fx\n"), .5);
1869 wxPrintf (_T("%#03x\n"), 1);
1871 //wxPrintf (_T("something really insane: %.10000f\n"), 1.0);
1877 while (niter
-- != 0)
1878 wxPrintf (_T("%.17e\n"), d
/ 2);
1883 // Open Watcom cause compiler error here
1884 // Error! E173: col(24) floating-point constant too small to represent
1885 wxPrintf (_T("%15.5e\n"), 4.9406564584124654e-324);
1888 #define FORMAT _T("|%12.4f|%12.4e|%12.4g|\n")
1889 wxPrintf (FORMAT
, 0.0, 0.0, 0.0);
1890 wxPrintf (FORMAT
, 1.0, 1.0, 1.0);
1891 wxPrintf (FORMAT
, -1.0, -1.0, -1.0);
1892 wxPrintf (FORMAT
, 100.0, 100.0, 100.0);
1893 wxPrintf (FORMAT
, 1000.0, 1000.0, 1000.0);
1894 wxPrintf (FORMAT
, 10000.0, 10000.0, 10000.0);
1895 wxPrintf (FORMAT
, 12345.0, 12345.0, 12345.0);
1896 wxPrintf (FORMAT
, 100000.0, 100000.0, 100000.0);
1897 wxPrintf (FORMAT
, 123456.0, 123456.0, 123456.0);
1902 int rc
= wxSnprintf (buf
, WXSIZEOF(buf
), _T("%30s"), _T("foo"));
1904 wxPrintf(_T("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1905 rc
, WXSIZEOF(buf
), buf
);
1908 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1909 wxSnprintf(buf2
, WXSIZEOFbuf2
), "%.999999u", 10));
1915 wxPrintf (_T("%e should be 1.234568e+06\n"), 1234567.8);
1916 wxPrintf (_T("%f should be 1234567.800000\n"), 1234567.8);
1917 wxPrintf (_T("%g should be 1.23457e+06\n"), 1234567.8);
1918 wxPrintf (_T("%g should be 123.456\n"), 123.456);
1919 wxPrintf (_T("%g should be 1e+06\n"), 1000000.0);
1920 wxPrintf (_T("%g should be 10\n"), 10.0);
1921 wxPrintf (_T("%g should be 0.02\n"), 0.02);
1925 wxPrintf(_T("%.17f\n"),(1.0/x
/10.0+1.0)*x
-x
);
1931 wxSprintf(buf
,_T("%*s%*s%*s"),-1,_T("one"),-20,_T("two"),-30,_T("three"));
1933 result
|= wxStrcmp (buf
,
1934 _T("onetwo three "));
1936 wxPuts (result
!= 0 ? _T("Test failed!") : _T("Test ok."));
1943 wxSprintf(buf
, _T("%07") wxLongLongFmtSpec
_T("o"), wxLL(040000000000));
1945 // for some reason below line fails under Borland
1946 wxPrintf (_T("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf
);
1949 if (wxStrcmp (buf
, _T("40000000000")) != 0)
1952 wxPuts (_T("\tFAILED"));
1954 wxUnusedVar(result
);
1955 wxPuts (wxEmptyString
);
1957 #endif // wxLongLong_t
1959 wxPrintf (_T("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX
+ 2, UCHAR_MAX
+ 2);
1960 wxPrintf (_T("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX
+ 2, USHRT_MAX
+ 2);
1962 wxPuts (_T("--- Should be no further output. ---"));
1971 memset (bytes
, '\xff', sizeof bytes
);
1972 wxSprintf (buf
, _T("foo%hhn\n"), &bytes
[3]);
1973 if (bytes
[0] != '\xff' || bytes
[1] != '\xff' || bytes
[2] != '\xff'
1974 || bytes
[4] != '\xff' || bytes
[5] != '\xff' || bytes
[6] != '\xff')
1976 wxPuts (_T("%hhn overwrite more bytes"));
1981 wxPuts (_T("%hhn wrote incorrect value"));
1993 wxSprintf (buf
, _T("%5.s"), _T("xyz"));
1994 if (wxStrcmp (buf
, _T(" ")) != 0)
1995 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" "));
1996 wxSprintf (buf
, _T("%5.f"), 33.3);
1997 if (wxStrcmp (buf
, _T(" 33")) != 0)
1998 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 33"));
1999 wxSprintf (buf
, _T("%8.e"), 33.3e7
);
2000 if (wxStrcmp (buf
, _T(" 3e+08")) != 0)
2001 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3e+08"));
2002 wxSprintf (buf
, _T("%8.E"), 33.3e7
);
2003 if (wxStrcmp (buf
, _T(" 3E+08")) != 0)
2004 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3E+08"));
2005 wxSprintf (buf
, _T("%.g"), 33.3);
2006 if (wxStrcmp (buf
, _T("3e+01")) != 0)
2007 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3e+01"));
2008 wxSprintf (buf
, _T("%.G"), 33.3);
2009 if (wxStrcmp (buf
, _T("3E+01")) != 0)
2010 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3E+01"));
2018 wxString test_format
;
2021 wxSprintf (buf
, _T("%.*g"), prec
, 3.3);
2022 if (wxStrcmp (buf
, _T("3")) != 0)
2023 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3"));
2025 wxSprintf (buf
, _T("%.*G"), prec
, 3.3);
2026 if (wxStrcmp (buf
, _T("3")) != 0)
2027 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3"));
2029 wxSprintf (buf
, _T("%7.*G"), prec
, 3.33);
2030 if (wxStrcmp (buf
, _T(" 3")) != 0)
2031 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3"));
2033 test_format
= _T("%04.*o");
2034 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2035 if (wxStrcmp (buf
, _T(" 041")) != 0)
2036 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 041"));
2038 test_format
= _T("%09.*u");
2039 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2040 if (wxStrcmp (buf
, _T(" 0000033")) != 0)
2041 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 0000033"));
2043 test_format
= _T("%04.*x");
2044 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2045 if (wxStrcmp (buf
, _T(" 021")) != 0)
2046 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 021"));
2048 test_format
= _T("%04.*X");
2049 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2050 if (wxStrcmp (buf
, _T(" 021")) != 0)
2051 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 021"));
2054 #endif // TEST_PRINTF
2056 // ----------------------------------------------------------------------------
2057 // registry and related stuff
2058 // ----------------------------------------------------------------------------
2060 // this is for MSW only
2063 #undef TEST_REGISTRY
2068 #include "wx/confbase.h"
2069 #include "wx/msw/regconf.h"
2072 static void TestRegConfWrite()
2074 wxConfig
*config
= new wxConfig(_T("myapp"));
2075 config
->SetPath(_T("/group1"));
2076 config
->Write(_T("entry1"), _T("foo"));
2077 config
->SetPath(_T("/group2"));
2078 config
->Write(_T("entry1"), _T("bar"));
2082 static void TestRegConfRead()
2084 wxConfig
*config
= new wxConfig(_T("myapp"));
2088 config
->SetPath(_T("/"));
2089 wxPuts(_T("Enumerating / subgroups:"));
2090 bool bCont
= config
->GetFirstGroup(str
, dummy
);
2094 bCont
= config
->GetNextGroup(str
, dummy
);
2098 #endif // TEST_REGCONF
2100 #ifdef TEST_REGISTRY
2102 #include "wx/msw/registry.h"
2104 // I chose this one because I liked its name, but it probably only exists under
2106 static const wxChar
*TESTKEY
=
2107 _T("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
2109 static void TestRegistryRead()
2111 wxPuts(_T("*** testing registry reading ***"));
2113 wxRegKey
key(TESTKEY
);
2114 wxPrintf(_T("The test key name is '%s'.\n"), key
.GetName().c_str());
2117 wxPuts(_T("ERROR: test key can't be opened, aborting test."));
2122 size_t nSubKeys
, nValues
;
2123 if ( key
.GetKeyInfo(&nSubKeys
, NULL
, &nValues
, NULL
) )
2125 wxPrintf(_T("It has %u subkeys and %u values.\n"), nSubKeys
, nValues
);
2128 wxPrintf(_T("Enumerating values:\n"));
2132 bool cont
= key
.GetFirstValue(value
, dummy
);
2135 wxPrintf(_T("Value '%s': type "), value
.c_str());
2136 switch ( key
.GetValueType(value
) )
2138 case wxRegKey::Type_None
: wxPrintf(_T("ERROR (none)")); break;
2139 case wxRegKey::Type_String
: wxPrintf(_T("SZ")); break;
2140 case wxRegKey::Type_Expand_String
: wxPrintf(_T("EXPAND_SZ")); break;
2141 case wxRegKey::Type_Binary
: wxPrintf(_T("BINARY")); break;
2142 case wxRegKey::Type_Dword
: wxPrintf(_T("DWORD")); break;
2143 case wxRegKey::Type_Multi_String
: wxPrintf(_T("MULTI_SZ")); break;
2144 default: wxPrintf(_T("other (unknown)")); break;
2147 wxPrintf(_T(", value = "));
2148 if ( key
.IsNumericValue(value
) )
2151 key
.QueryValue(value
, &val
);
2152 wxPrintf(_T("%ld"), val
);
2157 key
.QueryValue(value
, val
);
2158 wxPrintf(_T("'%s'"), val
.c_str());
2160 key
.QueryRawValue(value
, val
);
2161 wxPrintf(_T(" (raw value '%s')"), val
.c_str());
2166 cont
= key
.GetNextValue(value
, dummy
);
2170 static void TestRegistryAssociation()
2173 The second call to deleteself genertaes an error message, with a
2174 messagebox saying .flo is crucial to system operation, while the .ddf
2175 call also fails, but with no error message
2180 key
.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
2182 key
= _T("ddxf_auto_file") ;
2183 key
.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
2185 key
= _T("ddxf_auto_file") ;
2186 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2188 key
= _T("program,0") ;
2189 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2191 key
= _T("program \"%1\"") ;
2193 key
.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
2195 key
.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
2197 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2199 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2203 #endif // TEST_REGISTRY
2205 // ----------------------------------------------------------------------------
2207 // ----------------------------------------------------------------------------
2209 #ifdef TEST_SCOPEGUARD
2211 #include "wx/scopeguard.h"
2213 static void function0() { puts("function0()"); }
2214 static void function1(int n
) { printf("function1(%d)\n", n
); }
2215 static void function2(double x
, char c
) { printf("function2(%g, %c)\n", x
, c
); }
2219 void method0() { printf("method0()\n"); }
2220 void method1(int n
) { printf("method1(%d)\n", n
); }
2221 void method2(double x
, char c
) { printf("method2(%g, %c)\n", x
, c
); }
2224 static void TestScopeGuard()
2226 wxON_BLOCK_EXIT0(function0
);
2227 wxON_BLOCK_EXIT1(function1
, 17);
2228 wxON_BLOCK_EXIT2(function2
, 3.14, 'p');
2231 wxON_BLOCK_EXIT_OBJ0(obj
, Object::method0
);
2232 wxON_BLOCK_EXIT_OBJ1(obj
, Object::method1
, 7);
2233 wxON_BLOCK_EXIT_OBJ2(obj
, Object::method2
, 2.71, 'e');
2235 wxScopeGuard dismissed
= wxMakeGuard(function0
);
2236 dismissed
.Dismiss();
2241 // ----------------------------------------------------------------------------
2243 // ----------------------------------------------------------------------------
2247 #include "wx/socket.h"
2248 #include "wx/protocol/protocol.h"
2249 #include "wx/protocol/http.h"
2251 static void TestSocketServer()
2253 wxPuts(_T("*** Testing wxSocketServer ***\n"));
2255 static const int PORT
= 3000;
2260 wxSocketServer
*server
= new wxSocketServer(addr
);
2261 if ( !server
->Ok() )
2263 wxPuts(_T("ERROR: failed to bind"));
2271 wxPrintf(_T("Server: waiting for connection on port %d...\n"), PORT
);
2273 wxSocketBase
*socket
= server
->Accept();
2276 wxPuts(_T("ERROR: wxSocketServer::Accept() failed."));
2280 wxPuts(_T("Server: got a client."));
2282 server
->SetTimeout(60); // 1 min
2285 while ( !close
&& socket
->IsConnected() )
2288 wxChar ch
= _T('\0');
2291 if ( socket
->Read(&ch
, sizeof(ch
)).Error() )
2293 // don't log error if the client just close the connection
2294 if ( socket
->IsConnected() )
2296 wxPuts(_T("ERROR: in wxSocket::Read."));
2316 wxPrintf(_T("Server: got '%s'.\n"), s
.c_str());
2317 if ( s
== _T("close") )
2319 wxPuts(_T("Closing connection"));
2323 else if ( s
== _T("quit") )
2328 wxPuts(_T("Shutting down the server"));
2330 else // not a special command
2332 socket
->Write(s
.MakeUpper().c_str(), s
.length());
2333 socket
->Write("\r\n", 2);
2334 wxPrintf(_T("Server: wrote '%s'.\n"), s
.c_str());
2340 wxPuts(_T("Server: lost a client unexpectedly."));
2346 // same as "delete server" but is consistent with GUI programs
2350 static void TestSocketClient()
2352 wxPuts(_T("*** Testing wxSocketClient ***\n"));
2354 static const wxChar
*hostname
= _T("www.wxwidgets.org");
2357 addr
.Hostname(hostname
);
2360 wxPrintf(_T("--- Attempting to connect to %s:80...\n"), hostname
);
2362 wxSocketClient client
;
2363 if ( !client
.Connect(addr
) )
2365 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2369 wxPrintf(_T("--- Connected to %s:%u...\n"),
2370 addr
.Hostname().c_str(), addr
.Service());
2374 // could use simply "GET" here I suppose
2376 wxString::Format(_T("GET http://%s/\r\n"), hostname
);
2377 client
.Write(cmdGet
, cmdGet
.length());
2378 wxPrintf(_T("--- Sent command '%s' to the server\n"),
2379 MakePrintable(cmdGet
).c_str());
2380 client
.Read(buf
, WXSIZEOF(buf
));
2381 wxPrintf(_T("--- Server replied:\n%s"), buf
);
2385 #endif // TEST_SOCKETS
2387 // ----------------------------------------------------------------------------
2389 // ----------------------------------------------------------------------------
2393 #include "wx/protocol/ftp.h"
2397 #define FTP_ANONYMOUS
2399 #ifdef FTP_ANONYMOUS
2400 static const wxChar
*directory
= _T("/pub");
2401 static const wxChar
*filename
= _T("welcome.msg");
2403 static const wxChar
*directory
= _T("/etc");
2404 static const wxChar
*filename
= _T("issue");
2407 static bool TestFtpConnect()
2409 wxPuts(_T("*** Testing FTP connect ***"));
2411 #ifdef FTP_ANONYMOUS
2412 static const wxChar
*hostname
= _T("ftp.wxwidgets.org");
2414 wxPrintf(_T("--- Attempting to connect to %s:21 anonymously...\n"), hostname
);
2415 #else // !FTP_ANONYMOUS
2416 static const wxChar
*hostname
= "localhost";
2419 wxFgets(user
, WXSIZEOF(user
), stdin
);
2420 user
[wxStrlen(user
) - 1] = '\0'; // chop off '\n'
2423 wxChar password
[256];
2424 wxPrintf(_T("Password for %s: "), password
);
2425 wxFgets(password
, WXSIZEOF(password
), stdin
);
2426 password
[wxStrlen(password
) - 1] = '\0'; // chop off '\n'
2427 ftp
.SetPassword(password
);
2429 wxPrintf(_T("--- Attempting to connect to %s:21 as %s...\n"), hostname
, user
);
2430 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2432 if ( !ftp
.Connect(hostname
) )
2434 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2440 wxPrintf(_T("--- Connected to %s, current directory is '%s'\n"),
2441 hostname
, ftp
.Pwd().c_str());
2448 // test (fixed?) wxFTP bug with wu-ftpd >= 2.6.0?
2449 static void TestFtpWuFtpd()
2452 static const wxChar
*hostname
= _T("ftp.eudora.com");
2453 if ( !ftp
.Connect(hostname
) )
2455 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2459 static const wxChar
*filename
= _T("eudora/pubs/draft-gellens-submit-09.txt");
2460 wxInputStream
*in
= ftp
.GetInputStream(filename
);
2463 wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename
);
2467 size_t size
= in
->GetSize();
2468 wxPrintf(_T("Reading file %s (%u bytes)..."), filename
, size
);
2470 wxChar
*data
= new wxChar
[size
];
2471 if ( !in
->Read(data
, size
) )
2473 wxPuts(_T("ERROR: read error"));
2477 wxPrintf(_T("Successfully retrieved the file.\n"));
2486 static void TestFtpList()
2488 wxPuts(_T("*** Testing wxFTP file listing ***\n"));
2491 if ( !ftp
.ChDir(directory
) )
2493 wxPrintf(_T("ERROR: failed to cd to %s\n"), directory
);
2496 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2498 // test NLIST and LIST
2499 wxArrayString files
;
2500 if ( !ftp
.GetFilesList(files
) )
2502 wxPuts(_T("ERROR: failed to get NLIST of files"));
2506 wxPrintf(_T("Brief list of files under '%s':\n"), ftp
.Pwd().c_str());
2507 size_t count
= files
.GetCount();
2508 for ( size_t n
= 0; n
< count
; n
++ )
2510 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2512 wxPuts(_T("End of the file list"));
2515 if ( !ftp
.GetDirList(files
) )
2517 wxPuts(_T("ERROR: failed to get LIST of files"));
2521 wxPrintf(_T("Detailed list of files under '%s':\n"), ftp
.Pwd().c_str());
2522 size_t count
= files
.GetCount();
2523 for ( size_t n
= 0; n
< count
; n
++ )
2525 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2527 wxPuts(_T("End of the file list"));
2530 if ( !ftp
.ChDir(_T("..")) )
2532 wxPuts(_T("ERROR: failed to cd to .."));
2535 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2538 static void TestFtpDownload()
2540 wxPuts(_T("*** Testing wxFTP download ***\n"));
2543 wxInputStream
*in
= ftp
.GetInputStream(filename
);
2546 wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename
);
2550 size_t size
= in
->GetSize();
2551 wxPrintf(_T("Reading file %s (%u bytes)..."), filename
, size
);
2554 wxChar
*data
= new wxChar
[size
];
2555 if ( !in
->Read(data
, size
) )
2557 wxPuts(_T("ERROR: read error"));
2561 wxPrintf(_T("\nContents of %s:\n%s\n"), filename
, data
);
2569 static void TestFtpFileSize()
2571 wxPuts(_T("*** Testing FTP SIZE command ***"));
2573 if ( !ftp
.ChDir(directory
) )
2575 wxPrintf(_T("ERROR: failed to cd to %s\n"), directory
);
2578 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2580 if ( ftp
.FileExists(filename
) )
2582 int size
= ftp
.GetFileSize(filename
);
2584 wxPrintf(_T("ERROR: couldn't get size of '%s'\n"), filename
);
2586 wxPrintf(_T("Size of '%s' is %d bytes.\n"), filename
, size
);
2590 wxPrintf(_T("ERROR: '%s' doesn't exist\n"), filename
);
2594 static void TestFtpMisc()
2596 wxPuts(_T("*** Testing miscellaneous wxFTP functions ***"));
2598 if ( ftp
.SendCommand(_T("STAT")) != '2' )
2600 wxPuts(_T("ERROR: STAT failed"));
2604 wxPrintf(_T("STAT returned:\n\n%s\n"), ftp
.GetLastResult().c_str());
2607 if ( ftp
.SendCommand(_T("HELP SITE")) != '2' )
2609 wxPuts(_T("ERROR: HELP SITE failed"));
2613 wxPrintf(_T("The list of site-specific commands:\n\n%s\n"),
2614 ftp
.GetLastResult().c_str());
2618 static void TestFtpInteractive()
2620 wxPuts(_T("\n*** Interactive wxFTP test ***"));
2626 wxPrintf(_T("Enter FTP command: "));
2627 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2630 // kill the last '\n'
2631 buf
[wxStrlen(buf
) - 1] = 0;
2633 // special handling of LIST and NLST as they require data connection
2634 wxString
start(buf
, 4);
2636 if ( start
== _T("LIST") || start
== _T("NLST") )
2639 if ( wxStrlen(buf
) > 4 )
2642 wxArrayString files
;
2643 if ( !ftp
.GetList(files
, wildcard
, start
== _T("LIST")) )
2645 wxPrintf(_T("ERROR: failed to get %s of files\n"), start
.c_str());
2649 wxPrintf(_T("--- %s of '%s' under '%s':\n"),
2650 start
.c_str(), wildcard
.c_str(), ftp
.Pwd().c_str());
2651 size_t count
= files
.GetCount();
2652 for ( size_t n
= 0; n
< count
; n
++ )
2654 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2656 wxPuts(_T("--- End of the file list"));
2661 wxChar ch
= ftp
.SendCommand(buf
);
2662 wxPrintf(_T("Command %s"), ch
? _T("succeeded") : _T("failed"));
2665 wxPrintf(_T(" (return code %c)"), ch
);
2668 wxPrintf(_T(", server reply:\n%s\n\n"), ftp
.GetLastResult().c_str());
2672 wxPuts(_T("\n*** done ***"));
2675 static void TestFtpUpload()
2677 wxPuts(_T("*** Testing wxFTP uploading ***\n"));
2680 static const wxChar
*file1
= _T("test1");
2681 static const wxChar
*file2
= _T("test2");
2682 wxOutputStream
*out
= ftp
.GetOutputStream(file1
);
2685 wxPrintf(_T("--- Uploading to %s ---\n"), file1
);
2686 out
->Write("First hello", 11);
2690 // send a command to check the remote file
2691 if ( ftp
.SendCommand(wxString(_T("STAT ")) + file1
) != '2' )
2693 wxPrintf(_T("ERROR: STAT %s failed\n"), file1
);
2697 wxPrintf(_T("STAT %s returned:\n\n%s\n"),
2698 file1
, ftp
.GetLastResult().c_str());
2701 out
= ftp
.GetOutputStream(file2
);
2704 wxPrintf(_T("--- Uploading to %s ---\n"), file1
);
2705 out
->Write("Second hello", 12);
2712 // ----------------------------------------------------------------------------
2714 // ----------------------------------------------------------------------------
2716 #ifdef TEST_STACKWALKER
2718 #if wxUSE_STACKWALKER
2720 #include "wx/stackwalk.h"
2722 class StackDump
: public wxStackWalker
2725 StackDump(const char *argv0
)
2726 : wxStackWalker(argv0
)
2730 virtual void Walk(size_t skip
= 1)
2732 wxPuts(_T("Stack dump:"));
2734 wxStackWalker::Walk(skip
);
2738 virtual void OnStackFrame(const wxStackFrame
& frame
)
2740 printf("[%2d] ", frame
.GetLevel());
2742 wxString name
= frame
.GetName();
2743 if ( !name
.empty() )
2745 printf("%-20.40s", name
.mb_str());
2749 printf("0x%08lx", (unsigned long)frame
.GetAddress());
2752 if ( frame
.HasSourceLocation() )
2755 frame
.GetFileName().mb_str(),
2762 for ( size_t n
= 0; frame
.GetParam(n
, &type
, &name
, &val
); n
++ )
2764 printf("\t%s %s = %s\n", type
.mb_str(), name
.mb_str(), val
.mb_str());
2769 static void TestStackWalk(const char *argv0
)
2771 wxPuts(_T("*** Testing wxStackWalker ***\n"));
2773 StackDump
dump(argv0
);
2777 #endif // wxUSE_STACKWALKER
2779 #endif // TEST_STACKWALKER
2781 // ----------------------------------------------------------------------------
2783 // ----------------------------------------------------------------------------
2785 #ifdef TEST_STDPATHS
2787 #include "wx/stdpaths.h"
2788 #include "wx/wxchar.h" // wxPrintf
2790 static void TestStandardPaths()
2792 wxPuts(_T("*** Testing wxStandardPaths ***\n"));
2794 wxTheApp
->SetAppName(_T("console"));
2796 wxStandardPathsBase
& stdp
= wxStandardPaths::Get();
2797 wxPrintf(_T("Config dir (sys):\t%s\n"), stdp
.GetConfigDir().c_str());
2798 wxPrintf(_T("Config dir (user):\t%s\n"), stdp
.GetUserConfigDir().c_str());
2799 wxPrintf(_T("Data dir (sys):\t\t%s\n"), stdp
.GetDataDir().c_str());
2800 wxPrintf(_T("Data dir (sys local):\t%s\n"), stdp
.GetLocalDataDir().c_str());
2801 wxPrintf(_T("Data dir (user):\t%s\n"), stdp
.GetUserDataDir().c_str());
2802 wxPrintf(_T("Data dir (user local):\t%s\n"), stdp
.GetUserLocalDataDir().c_str());
2803 wxPrintf(_T("Documents dir:\t\t%s\n"), stdp
.GetDocumentsDir().c_str());
2804 wxPrintf(_T("Executable path:\t%s\n"), stdp
.GetExecutablePath().c_str());
2805 wxPrintf(_T("Plugins dir:\t\t%s\n"), stdp
.GetPluginsDir().c_str());
2806 wxPrintf(_T("Resources dir:\t\t%s\n"), stdp
.GetResourcesDir().c_str());
2807 wxPrintf(_T("Localized res. dir:\t%s\n"),
2808 stdp
.GetLocalizedResourcesDir(_T("fr")).c_str());
2809 wxPrintf(_T("Message catalogs dir:\t%s\n"),
2810 stdp
.GetLocalizedResourcesDir
2813 wxStandardPaths::ResourceCat_Messages
2817 #endif // TEST_STDPATHS
2819 // ----------------------------------------------------------------------------
2821 // ----------------------------------------------------------------------------
2825 #include "wx/wfstream.h"
2826 #include "wx/mstream.h"
2828 static void TestFileStream()
2830 wxPuts(_T("*** Testing wxFileInputStream ***"));
2832 static const wxString filename
= _T("testdata.fs");
2834 wxFileOutputStream
fsOut(filename
);
2835 fsOut
.Write("foo", 3);
2839 wxFileInputStream
fsIn(filename
);
2840 wxPrintf(_T("File stream size: %u\n"), fsIn
.GetSize());
2841 while ( !fsIn
.Eof() )
2843 wxPutchar(fsIn
.GetC());
2847 if ( !wxRemoveFile(filename
) )
2849 wxPrintf(_T("ERROR: failed to remove the file '%s'.\n"), filename
.c_str());
2852 wxPuts(_T("\n*** wxFileInputStream test done ***"));
2855 static void TestMemoryStream()
2857 wxPuts(_T("*** Testing wxMemoryOutputStream ***"));
2859 wxMemoryOutputStream memOutStream
;
2860 wxPrintf(_T("Initially out stream offset: %lu\n"),
2861 (unsigned long)memOutStream
.TellO());
2863 for ( const wxChar
*p
= _T("Hello, stream!"); *p
; p
++ )
2865 memOutStream
.PutC(*p
);
2868 wxPrintf(_T("Final out stream offset: %lu\n"),
2869 (unsigned long)memOutStream
.TellO());
2871 wxPuts(_T("*** Testing wxMemoryInputStream ***"));
2874 size_t len
= memOutStream
.CopyTo(buf
, WXSIZEOF(buf
));
2876 wxMemoryInputStream
memInpStream(buf
, len
);
2877 wxPrintf(_T("Memory stream size: %u\n"), memInpStream
.GetSize());
2878 while ( !memInpStream
.Eof() )
2880 wxPutchar(memInpStream
.GetC());
2883 wxPuts(_T("\n*** wxMemoryInputStream test done ***"));
2886 #endif // TEST_STREAMS
2888 // ----------------------------------------------------------------------------
2890 // ----------------------------------------------------------------------------
2894 #include "wx/stopwatch.h"
2895 #include "wx/utils.h"
2897 static void TestStopWatch()
2899 wxPuts(_T("*** Testing wxStopWatch ***\n"));
2903 wxPrintf(_T("Initially paused, after 2 seconds time is..."));
2906 wxPrintf(_T("\t%ldms\n"), sw
.Time());
2908 wxPrintf(_T("Resuming stopwatch and sleeping 3 seconds..."));
2912 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2915 wxPrintf(_T("Pausing agan and sleeping 2 more seconds..."));
2918 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2921 wxPrintf(_T("Finally resuming and sleeping 2 more seconds..."));
2924 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2927 wxPuts(_T("\nChecking for 'backwards clock' bug..."));
2928 for ( size_t n
= 0; n
< 70; n
++ )
2932 for ( size_t m
= 0; m
< 100000; m
++ )
2934 if ( sw
.Time() < 0 || sw2
.Time() < 0 )
2936 wxPuts(_T("\ntime is negative - ERROR!"));
2944 wxPuts(_T(", ok."));
2947 #include "wx/timer.h"
2948 #include "wx/evtloop.h"
2952 wxPuts(_T("*** Testing wxTimer ***\n"));
2954 class MyTimer
: public wxTimer
2957 MyTimer() : wxTimer() { m_num
= 0; }
2959 virtual void Notify()
2961 wxPrintf(_T("%d"), m_num
++);
2966 wxPrintf(_T("... exiting the event loop"));
2969 wxEventLoop::GetActive()->Exit(0);
2970 wxPuts(_T(", ok."));
2983 timer1
.Start(100, true /* one shot */);
2985 timer1
.Start(100, true /* one shot */);
2993 #endif // TEST_TIMER
2995 // ----------------------------------------------------------------------------
2997 // ----------------------------------------------------------------------------
3001 #include "wx/vcard.h"
3003 static void DumpVObject(size_t level
, const wxVCardObject
& vcard
)
3006 wxVCardObject
*vcObj
= vcard
.GetFirstProp(&cookie
);
3009 wxPrintf(_T("%s%s"),
3010 wxString(_T('\t'), level
).c_str(),
3011 vcObj
->GetName().c_str());
3014 switch ( vcObj
->GetType() )
3016 case wxVCardObject::String
:
3017 case wxVCardObject::UString
:
3020 vcObj
->GetValue(&val
);
3021 value
<< _T('"') << val
<< _T('"');
3025 case wxVCardObject::Int
:
3028 vcObj
->GetValue(&i
);
3029 value
.Printf(_T("%u"), i
);
3033 case wxVCardObject::Long
:
3036 vcObj
->GetValue(&l
);
3037 value
.Printf(_T("%lu"), l
);
3041 case wxVCardObject::None
:
3044 case wxVCardObject::Object
:
3045 value
= _T("<node>");
3049 value
= _T("<unknown value type>");
3053 wxPrintf(_T(" = %s"), value
.c_str());
3056 DumpVObject(level
+ 1, *vcObj
);
3059 vcObj
= vcard
.GetNextProp(&cookie
);
3063 static void DumpVCardAddresses(const wxVCard
& vcard
)
3065 wxPuts(_T("\nShowing all addresses from vCard:\n"));
3069 wxVCardAddress
*addr
= vcard
.GetFirstAddress(&cookie
);
3073 int flags
= addr
->GetFlags();
3074 if ( flags
& wxVCardAddress::Domestic
)
3076 flagsStr
<< _T("domestic ");
3078 if ( flags
& wxVCardAddress::Intl
)
3080 flagsStr
<< _T("international ");
3082 if ( flags
& wxVCardAddress::Postal
)
3084 flagsStr
<< _T("postal ");
3086 if ( flags
& wxVCardAddress::Parcel
)
3088 flagsStr
<< _T("parcel ");
3090 if ( flags
& wxVCardAddress::Home
)
3092 flagsStr
<< _T("home ");
3094 if ( flags
& wxVCardAddress::Work
)
3096 flagsStr
<< _T("work ");
3099 wxPrintf(_T("Address %u:\n")
3101 "\tvalue = %s;%s;%s;%s;%s;%s;%s\n",
3104 addr
->GetPostOffice().c_str(),
3105 addr
->GetExtAddress().c_str(),
3106 addr
->GetStreet().c_str(),
3107 addr
->GetLocality().c_str(),
3108 addr
->GetRegion().c_str(),
3109 addr
->GetPostalCode().c_str(),
3110 addr
->GetCountry().c_str()
3114 addr
= vcard
.GetNextAddress(&cookie
);
3118 static void DumpVCardPhoneNumbers(const wxVCard
& vcard
)
3120 wxPuts(_T("\nShowing all phone numbers from vCard:\n"));
3124 wxVCardPhoneNumber
*phone
= vcard
.GetFirstPhoneNumber(&cookie
);
3128 int flags
= phone
->GetFlags();
3129 if ( flags
& wxVCardPhoneNumber::Voice
)
3131 flagsStr
<< _T("voice ");
3133 if ( flags
& wxVCardPhoneNumber::Fax
)
3135 flagsStr
<< _T("fax ");
3137 if ( flags
& wxVCardPhoneNumber::Cellular
)
3139 flagsStr
<< _T("cellular ");
3141 if ( flags
& wxVCardPhoneNumber::Modem
)
3143 flagsStr
<< _T("modem ");
3145 if ( flags
& wxVCardPhoneNumber::Home
)
3147 flagsStr
<< _T("home ");
3149 if ( flags
& wxVCardPhoneNumber::Work
)
3151 flagsStr
<< _T("work ");
3154 wxPrintf(_T("Phone number %u:\n")
3159 phone
->GetNumber().c_str()
3163 phone
= vcard
.GetNextPhoneNumber(&cookie
);
3167 static void TestVCardRead()
3169 wxPuts(_T("*** Testing wxVCard reading ***\n"));
3171 wxVCard
vcard(_T("vcard.vcf"));
3172 if ( !vcard
.IsOk() )
3174 wxPuts(_T("ERROR: couldn't load vCard."));
3178 // read individual vCard properties
3179 wxVCardObject
*vcObj
= vcard
.GetProperty("FN");
3183 vcObj
->GetValue(&value
);
3188 value
= _T("<none>");
3191 wxPrintf(_T("Full name retrieved directly: %s\n"), value
.c_str());
3194 if ( !vcard
.GetFullName(&value
) )
3196 value
= _T("<none>");
3199 wxPrintf(_T("Full name from wxVCard API: %s\n"), value
.c_str());
3201 // now show how to deal with multiply occurring properties
3202 DumpVCardAddresses(vcard
);
3203 DumpVCardPhoneNumbers(vcard
);
3205 // and finally show all
3206 wxPuts(_T("\nNow dumping the entire vCard:\n")
3207 "-----------------------------\n");
3209 DumpVObject(0, vcard
);
3213 static void TestVCardWrite()
3215 wxPuts(_T("*** Testing wxVCard writing ***\n"));
3218 if ( !vcard
.IsOk() )
3220 wxPuts(_T("ERROR: couldn't create vCard."));
3225 vcard
.SetName("Zeitlin", "Vadim");
3226 vcard
.SetFullName("Vadim Zeitlin");
3227 vcard
.SetOrganization("wxWidgets", "R&D");
3229 // just dump the vCard back
3230 wxPuts(_T("Entire vCard follows:\n"));
3231 wxPuts(vcard
.Write());
3235 #endif // TEST_VCARD
3237 // ----------------------------------------------------------------------------
3239 // ----------------------------------------------------------------------------
3241 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
3247 #include "wx/volume.h"
3249 static const wxChar
*volumeKinds
[] =
3255 _T("network volume"),
3259 static void TestFSVolume()
3261 wxPuts(_T("*** Testing wxFSVolume class ***"));
3263 wxArrayString volumes
= wxFSVolume::GetVolumes();
3264 size_t count
= volumes
.GetCount();
3268 wxPuts(_T("ERROR: no mounted volumes?"));
3272 wxPrintf(_T("%u mounted volumes found:\n"), count
);
3274 for ( size_t n
= 0; n
< count
; n
++ )
3276 wxFSVolume
vol(volumes
[n
]);
3279 wxPuts(_T("ERROR: couldn't create volume"));
3283 wxPrintf(_T("%u: %s (%s), %s, %s, %s\n"),
3285 vol
.GetDisplayName().c_str(),
3286 vol
.GetName().c_str(),
3287 volumeKinds
[vol
.GetKind()],
3288 vol
.IsWritable() ? _T("rw") : _T("ro"),
3289 vol
.GetFlags() & wxFS_VOL_REMOVABLE
? _T("removable")
3294 #endif // TEST_VOLUME
3296 // ----------------------------------------------------------------------------
3297 // wide char and Unicode support
3298 // ----------------------------------------------------------------------------
3302 #include "wx/strconv.h"
3303 #include "wx/fontenc.h"
3304 #include "wx/encconv.h"
3305 #include "wx/buffer.h"
3307 static const unsigned char utf8koi8r
[] =
3309 208, 157, 208, 181, 209, 129, 208, 186, 208, 176, 208, 183, 208, 176,
3310 208, 189, 208, 189, 208, 190, 32, 208, 191, 208, 190, 209, 128, 208,
3311 176, 208, 180, 208, 190, 208, 178, 208, 176, 208, 187, 32, 208, 188,
3312 208, 181, 208, 189, 209, 143, 32, 209, 129, 208, 178, 208, 190, 208,
3313 181, 208, 185, 32, 208, 186, 209, 128, 209, 131, 209, 130, 208, 181,
3314 208, 185, 209, 136, 208, 181, 208, 185, 32, 208, 189, 208, 190, 208,
3315 178, 208, 190, 209, 129, 209, 130, 209, 140, 209, 142, 0
3318 static const unsigned char utf8iso8859_1
[] =
3320 0x53, 0x79, 0x73, 0x74, 0xc3, 0xa8, 0x6d, 0x65, 0x73, 0x20, 0x49, 0x6e,
3321 0x74, 0xc3, 0xa9, 0x67, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x65,
3322 0x6e, 0x20, 0x4d, 0xc3, 0xa9, 0x63, 0x61, 0x6e, 0x69, 0x71, 0x75, 0x65,
3323 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65,
3324 0x74, 0x20, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x71, 0x75, 0x65, 0
3327 static const unsigned char utf8Invalid
[] =
3329 0x3c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3e, 0x32, 0x30, 0x30,
3330 0x32, 0xe5, 0xb9, 0xb4, 0x30, 0x39, 0xe6, 0x9c, 0x88, 0x32, 0x35, 0xe6,
3331 0x97, 0xa5, 0x20, 0x30, 0x37, 0xe6, 0x99, 0x82, 0x33, 0x39, 0xe5, 0x88,
3332 0x86, 0x35, 0x37, 0xe7, 0xa7, 0x92, 0x3c, 0x2f, 0x64, 0x69, 0x73, 0x70,
3336 static const struct Utf8Data
3338 const unsigned char *text
;
3340 const wxChar
*charset
;
3341 wxFontEncoding encoding
;
3344 { utf8Invalid
, WXSIZEOF(utf8Invalid
), _T("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3345 { utf8koi8r
, WXSIZEOF(utf8koi8r
), _T("koi8-r"), wxFONTENCODING_KOI8
},
3346 { utf8iso8859_1
, WXSIZEOF(utf8iso8859_1
), _T("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3349 static void TestUtf8()
3351 wxPuts(_T("*** Testing UTF8 support ***\n"));
3356 for ( size_t n
= 0; n
< WXSIZEOF(utf8data
); n
++ )
3358 const Utf8Data
& u8d
= utf8data
[n
];
3359 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)u8d
.text
,
3360 WXSIZEOF(wbuf
)) == (size_t)-1 )
3362 wxPuts(_T("ERROR: UTF-8 decoding failed."));
3366 wxCSConv
conv(u8d
.charset
);
3367 if ( conv
.WC2MB(buf
, wbuf
, WXSIZEOF(buf
)) == (size_t)-1 )
3369 wxPrintf(_T("ERROR: conversion to %s failed.\n"), u8d
.charset
);
3373 wxPrintf(_T("String in %s: %s\n"), u8d
.charset
, buf
);
3377 wxString
s(wxConvUTF8
.cMB2WC((const char *)u8d
.text
));
3379 s
= _T("<< conversion failed >>");
3380 wxPrintf(_T("String in current cset: %s\n"), s
.c_str());
3384 wxPuts(wxEmptyString
);
3387 static void TestEncodingConverter()
3389 wxPuts(_T("*** Testing wxEncodingConverter ***\n"));
3391 // using wxEncodingConverter should give the same result as above
3394 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)utf8koi8r
,
3395 WXSIZEOF(utf8koi8r
)) == (size_t)-1 )
3397 wxPuts(_T("ERROR: UTF-8 decoding failed."));
3401 wxEncodingConverter ec
;
3402 ec
.Init(wxFONTENCODING_UNICODE
, wxFONTENCODING_KOI8
);
3403 ec
.Convert(wbuf
, buf
);
3404 wxPrintf(_T("The same KOI8-R string using wxEC: %s\n"), buf
);
3407 wxPuts(wxEmptyString
);
3410 #endif // TEST_WCHAR
3412 // ----------------------------------------------------------------------------
3414 // ----------------------------------------------------------------------------
3418 #include "wx/filesys.h"
3419 #include "wx/fs_zip.h"
3420 #include "wx/zipstrm.h"
3422 static const wxChar
*TESTFILE_ZIP
= _T("testdata.zip");
3424 static void TestZipStreamRead()
3426 wxPuts(_T("*** Testing ZIP reading ***\n"));
3428 static const wxString filename
= _T("foo");
3429 wxZipInputStream
istr(TESTFILE_ZIP
, filename
);
3430 wxPrintf(_T("Archive size: %u\n"), istr
.GetSize());
3432 wxPrintf(_T("Dumping the file '%s':\n"), filename
.c_str());
3433 while ( !istr
.Eof() )
3435 wxPutchar(istr
.GetC());
3439 wxPuts(_T("\n----- done ------"));
3442 static void DumpZipDirectory(wxFileSystem
& fs
,
3443 const wxString
& dir
,
3444 const wxString
& indent
)
3446 wxString prefix
= wxString::Format(_T("%s#zip:%s"),
3447 TESTFILE_ZIP
, dir
.c_str());
3448 wxString wildcard
= prefix
+ _T("/*");
3450 wxString dirname
= fs
.FindFirst(wildcard
, wxDIR
);
3451 while ( !dirname
.empty() )
3453 if ( !dirname
.StartsWith(prefix
+ _T('/'), &dirname
) )
3455 wxPrintf(_T("ERROR: unexpected wxFileSystem::FindNext result\n"));
3460 wxPrintf(_T("%s%s\n"), indent
.c_str(), dirname
.c_str());
3462 DumpZipDirectory(fs
, dirname
,
3463 indent
+ wxString(_T(' '), 4));
3465 dirname
= fs
.FindNext();
3468 wxString filename
= fs
.FindFirst(wildcard
, wxFILE
);
3469 while ( !filename
.empty() )
3471 if ( !filename
.StartsWith(prefix
, &filename
) )
3473 wxPrintf(_T("ERROR: unexpected wxFileSystem::FindNext result\n"));
3478 wxPrintf(_T("%s%s\n"), indent
.c_str(), filename
.c_str());
3480 filename
= fs
.FindNext();
3484 static void TestZipFileSystem()
3486 wxPuts(_T("*** Testing ZIP file system ***\n"));
3488 wxFileSystem::AddHandler(new wxZipFSHandler
);
3490 wxPrintf(_T("Dumping all files in the archive %s:\n"), TESTFILE_ZIP
);
3492 DumpZipDirectory(fs
, _T(""), wxString(_T(' '), 4));
3497 // ----------------------------------------------------------------------------
3499 // ----------------------------------------------------------------------------
3501 #ifdef TEST_DATETIME
3503 #include "wx/math.h"
3504 #include "wx/datetime.h"
3506 // this test miscellaneous static wxDateTime functions
3510 static void TestTimeStatic()
3512 wxPuts(_T("\n*** wxDateTime static methods test ***"));
3514 // some info about the current date
3515 int year
= wxDateTime::GetCurrentYear();
3516 wxPrintf(_T("Current year %d is %sa leap one and has %d days.\n"),
3518 wxDateTime::IsLeapYear(year
) ? "" : "not ",
3519 wxDateTime::GetNumberOfDays(year
));
3521 wxDateTime::Month month
= wxDateTime::GetCurrentMonth();
3522 wxPrintf(_T("Current month is '%s' ('%s') and it has %d days\n"),
3523 wxDateTime::GetMonthName(month
, wxDateTime::Name_Abbr
).c_str(),
3524 wxDateTime::GetMonthName(month
).c_str(),
3525 wxDateTime::GetNumberOfDays(month
));
3528 // test time zones stuff
3529 static void TestTimeZones()
3531 wxPuts(_T("\n*** wxDateTime timezone test ***"));
3533 wxDateTime now
= wxDateTime::Now();
3535 wxPrintf(_T("Current GMT time:\t%s\n"), now
.Format(_T("%c"), wxDateTime::GMT0
).c_str());
3536 wxPrintf(_T("Unix epoch (GMT):\t%s\n"), wxDateTime((time_t)0).Format(_T("%c"), wxDateTime::GMT0
).c_str());
3537 wxPrintf(_T("Unix epoch (EST):\t%s\n"), wxDateTime((time_t)0).Format(_T("%c"), wxDateTime::EST
).c_str());
3538 wxPrintf(_T("Current time in Paris:\t%s\n"), now
.Format(_T("%c"), wxDateTime::CET
).c_str());
3539 wxPrintf(_T(" Moscow:\t%s\n"), now
.Format(_T("%c"), wxDateTime::MSK
).c_str());
3540 wxPrintf(_T(" New York:\t%s\n"), now
.Format(_T("%c"), wxDateTime::EST
).c_str());
3542 wxPrintf(_T("%s\n"), wxDateTime::Now().Format(_T("Our timezone is %Z")).c_str());
3544 wxDateTime::Tm tm
= now
.GetTm();
3545 if ( wxDateTime(tm
) != now
)
3547 wxPrintf(_T("ERROR: got %s instead of %s\n"),
3548 wxDateTime(tm
).Format().c_str(), now
.Format().c_str());
3552 // test some minimal support for the dates outside the standard range
3553 static void TestTimeRange()
3555 wxPuts(_T("\n*** wxDateTime out-of-standard-range dates test ***"));
3557 static const wxChar
*fmt
= _T("%d-%b-%Y %H:%M:%S");
3559 wxPrintf(_T("Unix epoch:\t%s\n"),
3560 wxDateTime(2440587.5).Format(fmt
).c_str());
3561 wxPrintf(_T("Feb 29, 0: \t%s\n"),
3562 wxDateTime(29, wxDateTime::Feb
, 0).Format(fmt
).c_str());
3563 wxPrintf(_T("JDN 0: \t%s\n"),
3564 wxDateTime(0.0).Format(fmt
).c_str());
3565 wxPrintf(_T("Jan 1, 1AD:\t%s\n"),
3566 wxDateTime(1, wxDateTime::Jan
, 1).Format(fmt
).c_str());
3567 wxPrintf(_T("May 29, 2099:\t%s\n"),
3568 wxDateTime(29, wxDateTime::May
, 2099).Format(fmt
).c_str());
3571 // test DST calculations
3572 static void TestTimeDST()
3574 wxPuts(_T("\n*** wxDateTime DST test ***"));
3576 wxPrintf(_T("DST is%s in effect now.\n\n"),
3577 wxDateTime::Now().IsDST() ? wxEmptyString
: _T(" not"));
3579 for ( int year
= 1990; year
< 2005; year
++ )
3581 wxPrintf(_T("DST period in Europe for year %d: from %s to %s\n"),
3583 wxDateTime::GetBeginDST(year
, wxDateTime::Country_EEC
).Format().c_str(),
3584 wxDateTime::GetEndDST(year
, wxDateTime::Country_EEC
).Format().c_str());
3590 #if TEST_INTERACTIVE
3592 static void TestDateTimeInteractive()
3594 wxPuts(_T("\n*** interactive wxDateTime tests ***"));
3600 wxPrintf(_T("Enter a date: "));
3601 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
3604 // kill the last '\n'
3605 buf
[wxStrlen(buf
) - 1] = 0;
3608 const wxChar
*p
= dt
.ParseDate(buf
);
3611 wxPrintf(_T("ERROR: failed to parse the date '%s'.\n"), buf
);
3617 wxPrintf(_T("WARNING: parsed only first %u characters.\n"), p
- buf
);
3620 wxPrintf(_T("%s: day %u, week of month %u/%u, week of year %u\n"),
3621 dt
.Format(_T("%b %d, %Y")).c_str(),
3623 dt
.GetWeekOfMonth(wxDateTime::Monday_First
),
3624 dt
.GetWeekOfMonth(wxDateTime::Sunday_First
),
3625 dt
.GetWeekOfYear(wxDateTime::Monday_First
));
3628 wxPuts(_T("\n*** done ***"));
3631 #endif // TEST_INTERACTIVE
3635 static void TestTimeMS()
3637 wxPuts(_T("*** testing millisecond-resolution support in wxDateTime ***"));
3639 wxDateTime dt1
= wxDateTime::Now(),
3640 dt2
= wxDateTime::UNow();
3642 wxPrintf(_T("Now = %s\n"), dt1
.Format(_T("%H:%M:%S:%l")).c_str());
3643 wxPrintf(_T("UNow = %s\n"), dt2
.Format(_T("%H:%M:%S:%l")).c_str());
3644 wxPrintf(_T("Dummy loop: "));
3645 for ( int i
= 0; i
< 6000; i
++ )
3647 //for ( int j = 0; j < 10; j++ )
3650 s
.Printf(_T("%g"), sqrt((float)i
));
3656 wxPuts(_T(", done"));
3659 dt2
= wxDateTime::UNow();
3660 wxPrintf(_T("UNow = %s\n"), dt2
.Format(_T("%H:%M:%S:%l")).c_str());
3662 wxPrintf(_T("Loop executed in %s ms\n"), (dt2
- dt1
).Format(_T("%l")).c_str());
3664 wxPuts(_T("\n*** done ***"));
3667 static void TestTimeHolidays()
3669 wxPuts(_T("\n*** testing wxDateTimeHolidayAuthority ***\n"));
3671 wxDateTime::Tm tm
= wxDateTime(29, wxDateTime::May
, 2000).GetTm();
3672 wxDateTime
dtStart(1, tm
.mon
, tm
.year
),
3673 dtEnd
= dtStart
.GetLastMonthDay();
3675 wxDateTimeArray hol
;
3676 wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart
, dtEnd
, hol
);
3678 const wxChar
*format
= _T("%d-%b-%Y (%a)");
3680 wxPrintf(_T("All holidays between %s and %s:\n"),
3681 dtStart
.Format(format
).c_str(), dtEnd
.Format(format
).c_str());
3683 size_t count
= hol
.GetCount();
3684 for ( size_t n
= 0; n
< count
; n
++ )
3686 wxPrintf(_T("\t%s\n"), hol
[n
].Format(format
).c_str());
3689 wxPuts(wxEmptyString
);
3692 static void TestTimeZoneBug()
3694 wxPuts(_T("\n*** testing for DST/timezone bug ***\n"));
3696 wxDateTime date
= wxDateTime(1, wxDateTime::Mar
, 2000);
3697 for ( int i
= 0; i
< 31; i
++ )
3699 wxPrintf(_T("Date %s: week day %s.\n"),
3700 date
.Format(_T("%d-%m-%Y")).c_str(),
3701 date
.GetWeekDayName(date
.GetWeekDay()).c_str());
3703 date
+= wxDateSpan::Day();
3706 wxPuts(wxEmptyString
);
3709 static void TestTimeSpanFormat()
3711 wxPuts(_T("\n*** wxTimeSpan tests ***"));
3713 static const wxChar
*formats
[] =
3715 _T("(default) %H:%M:%S"),
3716 _T("%E weeks and %D days"),
3717 _T("%l milliseconds"),
3718 _T("(with ms) %H:%M:%S:%l"),
3719 _T("100%% of minutes is %M"), // test "%%"
3720 _T("%D days and %H hours"),
3721 _T("or also %S seconds"),
3724 wxTimeSpan
ts1(1, 2, 3, 4),
3726 for ( size_t n
= 0; n
< WXSIZEOF(formats
); n
++ )
3728 wxPrintf(_T("ts1 = %s\tts2 = %s\n"),
3729 ts1
.Format(formats
[n
]).c_str(),
3730 ts2
.Format(formats
[n
]).c_str());
3733 wxPuts(wxEmptyString
);
3738 #endif // TEST_DATETIME
3740 // ----------------------------------------------------------------------------
3741 // wxTextInput/OutputStream
3742 // ----------------------------------------------------------------------------
3744 #ifdef TEST_TEXTSTREAM
3746 #include "wx/txtstrm.h"
3747 #include "wx/wfstream.h"
3749 static void TestTextInputStream()
3751 wxPuts(_T("\n*** wxTextInputStream test ***"));
3753 wxString filename
= _T("testdata.fc");
3754 wxFileInputStream
fsIn(filename
);
3757 wxPuts(_T("ERROR: couldn't open file."));
3761 wxTextInputStream
tis(fsIn
);
3766 const wxString s
= tis
.ReadLine();
3768 // line could be non empty if the last line of the file isn't
3769 // terminated with EOL
3770 if ( fsIn
.Eof() && s
.empty() )
3773 wxPrintf(_T("Line %d: %s\n"), line
++, s
.c_str());
3778 #endif // TEST_TEXTSTREAM
3780 // ----------------------------------------------------------------------------
3782 // ----------------------------------------------------------------------------
3786 #include "wx/thread.h"
3788 static size_t gs_counter
= (size_t)-1;
3789 static wxCriticalSection gs_critsect
;
3790 static wxSemaphore gs_cond
;
3792 class MyJoinableThread
: public wxThread
3795 MyJoinableThread(size_t n
) : wxThread(wxTHREAD_JOINABLE
)
3796 { m_n
= n
; Create(); }
3798 // thread execution starts here
3799 virtual ExitCode
Entry();
3805 wxThread::ExitCode
MyJoinableThread::Entry()
3807 unsigned long res
= 1;
3808 for ( size_t n
= 1; n
< m_n
; n
++ )
3812 // it's a loooong calculation :-)
3816 return (ExitCode
)res
;
3819 class MyDetachedThread
: public wxThread
3822 MyDetachedThread(size_t n
, wxChar ch
)
3826 m_cancelled
= false;
3831 // thread execution starts here
3832 virtual ExitCode
Entry();
3835 virtual void OnExit();
3838 size_t m_n
; // number of characters to write
3839 wxChar m_ch
; // character to write
3841 bool m_cancelled
; // false if we exit normally
3844 wxThread::ExitCode
MyDetachedThread::Entry()
3847 wxCriticalSectionLocker
lock(gs_critsect
);
3848 if ( gs_counter
== (size_t)-1 )
3854 for ( size_t n
= 0; n
< m_n
; n
++ )
3856 if ( TestDestroy() )
3866 wxThread::Sleep(100);
3872 void MyDetachedThread::OnExit()
3874 wxLogTrace(_T("thread"), _T("Thread %ld is in OnExit"), GetId());
3876 wxCriticalSectionLocker
lock(gs_critsect
);
3877 if ( !--gs_counter
&& !m_cancelled
)
3881 static void TestDetachedThreads()
3883 wxPuts(_T("\n*** Testing detached threads ***"));
3885 static const size_t nThreads
= 3;
3886 MyDetachedThread
*threads
[nThreads
];
3888 for ( n
= 0; n
< nThreads
; n
++ )
3890 threads
[n
] = new MyDetachedThread(10, 'A' + n
);
3893 threads
[0]->SetPriority(WXTHREAD_MIN_PRIORITY
);
3894 threads
[1]->SetPriority(WXTHREAD_MAX_PRIORITY
);
3896 for ( n
= 0; n
< nThreads
; n
++ )
3901 // wait until all threads terminate
3904 wxPuts(wxEmptyString
);
3907 static void TestJoinableThreads()
3909 wxPuts(_T("\n*** Testing a joinable thread (a loooong calculation...) ***"));
3911 // calc 10! in the background
3912 MyJoinableThread
thread(10);
3915 wxPrintf(_T("\nThread terminated with exit code %lu.\n"),
3916 (unsigned long)thread
.Wait());
3919 static void TestThreadSuspend()
3921 wxPuts(_T("\n*** Testing thread suspend/resume functions ***"));
3923 MyDetachedThread
*thread
= new MyDetachedThread(15, 'X');
3927 // this is for this demo only, in a real life program we'd use another
3928 // condition variable which would be signaled from wxThread::Entry() to
3929 // tell us that the thread really started running - but here just wait a
3930 // bit and hope that it will be enough (the problem is, of course, that
3931 // the thread might still not run when we call Pause() which will result
3933 wxThread::Sleep(300);
3935 for ( size_t n
= 0; n
< 3; n
++ )
3939 wxPuts(_T("\nThread suspended"));
3942 // don't sleep but resume immediately the first time
3943 wxThread::Sleep(300);
3945 wxPuts(_T("Going to resume the thread"));
3950 wxPuts(_T("Waiting until it terminates now"));
3952 // wait until the thread terminates
3955 wxPuts(wxEmptyString
);
3958 static void TestThreadDelete()
3960 // As above, using Sleep() is only for testing here - we must use some
3961 // synchronisation object instead to ensure that the thread is still
3962 // running when we delete it - deleting a detached thread which already
3963 // terminated will lead to a crash!
3965 wxPuts(_T("\n*** Testing thread delete function ***"));
3967 MyDetachedThread
*thread0
= new MyDetachedThread(30, 'W');
3971 wxPuts(_T("\nDeleted a thread which didn't start to run yet."));
3973 MyDetachedThread
*thread1
= new MyDetachedThread(30, 'Y');
3977 wxThread::Sleep(300);
3981 wxPuts(_T("\nDeleted a running thread."));
3983 MyDetachedThread
*thread2
= new MyDetachedThread(30, 'Z');
3987 wxThread::Sleep(300);
3993 wxPuts(_T("\nDeleted a sleeping thread."));
3995 MyJoinableThread
thread3(20);
4000 wxPuts(_T("\nDeleted a joinable thread."));
4002 MyJoinableThread
thread4(2);
4005 wxThread::Sleep(300);
4009 wxPuts(_T("\nDeleted a joinable thread which already terminated."));
4011 wxPuts(wxEmptyString
);
4014 class MyWaitingThread
: public wxThread
4017 MyWaitingThread( wxMutex
*mutex
, wxCondition
*condition
)
4020 m_condition
= condition
;
4025 virtual ExitCode
Entry()
4027 wxPrintf(_T("Thread %lu has started running.\n"), GetId());
4032 wxPrintf(_T("Thread %lu starts to wait...\n"), GetId());
4036 m_condition
->Wait();
4039 wxPrintf(_T("Thread %lu finished to wait, exiting.\n"), GetId());
4047 wxCondition
*m_condition
;
4050 static void TestThreadConditions()
4053 wxCondition
condition(mutex
);
4055 // otherwise its difficult to understand which log messages pertain to
4057 //wxLogTrace(_T("thread"), _T("Local condition var is %08x, gs_cond = %08x"),
4058 // condition.GetId(), gs_cond.GetId());
4060 // create and launch threads
4061 MyWaitingThread
*threads
[10];
4064 for ( n
= 0; n
< WXSIZEOF(threads
); n
++ )
4066 threads
[n
] = new MyWaitingThread( &mutex
, &condition
);
4069 for ( n
= 0; n
< WXSIZEOF(threads
); n
++ )
4074 // wait until all threads run
4075 wxPuts(_T("Main thread is waiting for the other threads to start"));
4078 size_t nRunning
= 0;
4079 while ( nRunning
< WXSIZEOF(threads
) )
4085 wxPrintf(_T("Main thread: %u already running\n"), nRunning
);
4089 wxPuts(_T("Main thread: all threads started up."));
4092 wxThread::Sleep(500);
4095 // now wake one of them up
4096 wxPrintf(_T("Main thread: about to signal the condition.\n"));
4101 wxThread::Sleep(200);
4103 // wake all the (remaining) threads up, so that they can exit
4104 wxPrintf(_T("Main thread: about to broadcast the condition.\n"));
4106 condition
.Broadcast();
4108 // give them time to terminate (dirty!)
4109 wxThread::Sleep(500);
4112 #include "wx/utils.h"
4114 class MyExecThread
: public wxThread
4117 MyExecThread(const wxString
& command
) : wxThread(wxTHREAD_JOINABLE
),
4123 virtual ExitCode
Entry()
4125 return (ExitCode
)wxExecute(m_command
, wxEXEC_SYNC
);
4132 static void TestThreadExec()
4134 wxPuts(_T("*** Testing wxExecute interaction with threads ***\n"));
4136 MyExecThread
thread(_T("true"));
4139 wxPrintf(_T("Main program exit code: %ld.\n"),
4140 wxExecute(_T("false"), wxEXEC_SYNC
));
4142 wxPrintf(_T("Thread exit code: %ld.\n"), (long)thread
.Wait());
4146 #include "wx/datetime.h"
4148 class MySemaphoreThread
: public wxThread
4151 MySemaphoreThread(int i
, wxSemaphore
*sem
)
4152 : wxThread(wxTHREAD_JOINABLE
),
4159 virtual ExitCode
Entry()
4161 wxPrintf(_T("%s: Thread #%d (%ld) starting to wait for semaphore...\n"),
4162 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4166 wxPrintf(_T("%s: Thread #%d (%ld) acquired the semaphore.\n"),
4167 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4171 wxPrintf(_T("%s: Thread #%d (%ld) releasing the semaphore.\n"),
4172 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4184 WX_DEFINE_ARRAY_PTR(wxThread
*, ArrayThreads
);
4186 static void TestSemaphore()
4188 wxPuts(_T("*** Testing wxSemaphore class. ***"));
4190 static const int SEM_LIMIT
= 3;
4192 wxSemaphore
sem(SEM_LIMIT
, SEM_LIMIT
);
4193 ArrayThreads threads
;
4195 for ( int i
= 0; i
< 3*SEM_LIMIT
; i
++ )
4197 threads
.Add(new MySemaphoreThread(i
, &sem
));
4198 threads
.Last()->Run();
4201 for ( size_t n
= 0; n
< threads
.GetCount(); n
++ )
4208 #endif // TEST_THREADS
4210 // ----------------------------------------------------------------------------
4212 // ----------------------------------------------------------------------------
4214 #ifdef TEST_SNGLINST
4215 #include "wx/snglinst.h"
4216 #endif // TEST_SNGLINST
4218 int main(int argc
, char **argv
)
4221 wxChar
**wxArgv
= new wxChar
*[argc
+ 1];
4226 for (n
= 0; n
< argc
; n
++ )
4228 wxMB2WXbuf warg
= wxConvertMB2WX(argv
[n
]);
4229 wxArgv
[n
] = wxStrdup(warg
);
4234 #else // !wxUSE_UNICODE
4236 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
4238 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE
, "program");
4240 wxInitializer initializer
;
4243 fprintf(stderr
, "Failed to initialize the wxWidgets library, aborting.");
4248 #ifdef TEST_SNGLINST
4249 wxSingleInstanceChecker checker
;
4250 if ( checker
.Create(_T(".wxconsole.lock")) )
4252 if ( checker
.IsAnotherRunning() )
4254 wxPrintf(_T("Another instance of the program is running, exiting.\n"));
4259 // wait some time to give time to launch another instance
4260 wxPrintf(_T("Press \"Enter\" to continue..."));
4263 else // failed to create
4265 wxPrintf(_T("Failed to init wxSingleInstanceChecker.\n"));
4267 #endif // TEST_SNGLINST
4270 TestCmdLineConvert();
4272 #if wxUSE_CMDLINE_PARSER
4273 static const wxCmdLineEntryDesc cmdLineDesc
[] =
4275 { wxCMD_LINE_SWITCH
, _T("h"), _T("help"), _T("show this help message"),
4276 wxCMD_LINE_VAL_NONE
, wxCMD_LINE_OPTION_HELP
},
4277 { wxCMD_LINE_SWITCH
, _T("v"), _T("verbose"), _T("be verbose") },
4278 { wxCMD_LINE_SWITCH
, _T("q"), _T("quiet"), _T("be quiet") },
4280 { wxCMD_LINE_OPTION
, _T("o"), _T("output"), _T("output file") },
4281 { wxCMD_LINE_OPTION
, _T("i"), _T("input"), _T("input dir") },
4282 { wxCMD_LINE_OPTION
, _T("s"), _T("size"), _T("output block size"),
4283 wxCMD_LINE_VAL_NUMBER
},
4284 { wxCMD_LINE_OPTION
, _T("d"), _T("date"), _T("output file date"),
4285 wxCMD_LINE_VAL_DATE
},
4287 { wxCMD_LINE_PARAM
, NULL
, NULL
, _T("input file"),
4288 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_MULTIPLE
},
4293 wxCmdLineParser
parser(cmdLineDesc
, argc
, wxArgv
);
4295 parser
.AddOption(_T("project_name"), _T(""), _T("full path to project file"),
4296 wxCMD_LINE_VAL_STRING
,
4297 wxCMD_LINE_OPTION_MANDATORY
| wxCMD_LINE_NEEDS_SEPARATOR
);
4299 switch ( parser
.Parse() )
4302 wxLogMessage(_T("Help was given, terminating."));
4306 ShowCmdLine(parser
);
4310 wxLogMessage(_T("Syntax error detected, aborting."));
4313 #endif // wxUSE_CMDLINE_PARSER
4315 #endif // TEST_CMDLINE
4327 TestDllListLoaded();
4328 #endif // TEST_DYNLIB
4332 #endif // TEST_ENVIRON
4336 #endif // TEST_EXECUTE
4338 #ifdef TEST_FILECONF
4340 #endif // TEST_FILECONF
4344 #endif // TEST_LOCALE
4347 wxPuts(_T("*** Testing wxLog ***"));
4350 for ( size_t n
= 0; n
< 8000; n
++ )
4352 s
<< (wxChar
)(_T('A') + (n
% 26));
4355 wxLogWarning(_T("The length of the string is %lu"),
4356 (unsigned long)s
.length());
4359 msg
.Printf(_T("A very very long message: '%s', the end!\n"), s
.c_str());
4361 // this one shouldn't be truncated
4364 // but this one will because log functions use fixed size buffer
4365 // (note that it doesn't need '\n' at the end neither - will be added
4367 wxLogMessage(_T("A very very long message 2: '%s', the end!"), s
.c_str());
4377 #ifdef TEST_FILENAME
4380 TestFileNameDirManip();
4381 TestFileNameComparison();
4382 TestFileNameOperations();
4383 #endif // TEST_FILENAME
4385 #ifdef TEST_FILETIME
4390 #endif // TEST_FILETIME
4393 wxLog::AddTraceMask(FTP_TRACE_MASK
);
4394 if ( TestFtpConnect() )
4404 #if TEST_INTERACTIVE
4405 TestFtpInteractive();
4408 //else: connecting to the FTP server failed
4416 wxLog::AddTraceMask(_T("mime"));
4421 TestMimeAssociate();
4425 #ifdef TEST_INFO_FUNCTIONS
4430 #if TEST_INTERACTIVE
4433 #endif // TEST_INFO_FUNCTIONS
4435 #ifdef TEST_PATHLIST
4437 #endif // TEST_PATHLIST
4445 #endif // TEST_PRINTF
4452 #endif // TEST_REGCONF
4454 #if defined TEST_REGEX && TEST_INTERACTIVE
4455 TestRegExInteractive();
4456 #endif // defined TEST_REGEX && TEST_INTERACTIVE
4458 #ifdef TEST_REGISTRY
4460 TestRegistryAssociation();
4461 #endif // TEST_REGISTRY
4466 #endif // TEST_SOCKETS
4473 #endif // TEST_STREAMS
4475 #ifdef TEST_TEXTSTREAM
4476 TestTextInputStream();
4477 #endif // TEST_TEXTSTREAM
4480 int nCPUs
= wxThread::GetCPUCount();
4481 wxPrintf(_T("This system has %d CPUs\n"), nCPUs
);
4483 wxThread::SetConcurrency(nCPUs
);
4485 TestJoinableThreads();
4488 TestJoinableThreads();
4489 TestDetachedThreads();
4490 TestThreadSuspend();
4492 TestThreadConditions();
4496 #endif // TEST_THREADS
4501 #endif // TEST_TIMER
4503 #ifdef TEST_DATETIME
4510 TestTimeSpanFormat();
4516 #if TEST_INTERACTIVE
4517 TestDateTimeInteractive();
4519 #endif // TEST_DATETIME
4521 #ifdef TEST_SCOPEGUARD
4525 #ifdef TEST_STACKWALKER
4526 #if wxUSE_STACKWALKER
4527 TestStackWalk(argv
[0]);
4529 #endif // TEST_STACKWALKER
4531 #ifdef TEST_STDPATHS
4532 TestStandardPaths();
4536 wxPuts(_T("Sleeping for 3 seconds... z-z-z-z-z..."));
4538 #endif // TEST_USLEEP
4543 #endif // TEST_VCARD
4547 #endif // TEST_VOLUME
4551 TestEncodingConverter();
4552 #endif // TEST_WCHAR
4555 TestZipStreamRead();
4556 TestZipFileSystem();
4561 for ( int n
= 0; n
< argc
; n
++ )
4566 #endif // wxUSE_UNICODE