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
77 #define TEST_SCOPEGUARD
79 // #define TEST_SOCKETS --FIXME! (RN)
80 #define TEST_STACKWALKER
83 #define TEST_TEXTSTREAM
86 // #define TEST_VCARD -- don't enable this (VZ)
87 // #define TEST_VOLUME --FIXME! (RN)
94 // some tests are interactive, define this to run them
95 #ifdef TEST_INTERACTIVE
96 #undef TEST_INTERACTIVE
98 #define TEST_INTERACTIVE 1
100 #define TEST_INTERACTIVE 0
103 // ============================================================================
105 // ============================================================================
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 #if defined(TEST_SOCKETS)
113 // replace TABs with \t and CRs with \n
114 static wxString
MakePrintable(const wxChar
*s
)
117 (void)str
.Replace(_T("\t"), _T("\\t"));
118 (void)str
.Replace(_T("\n"), _T("\\n"));
119 (void)str
.Replace(_T("\r"), _T("\\r"));
124 #endif // MakePrintable() is used
126 // ----------------------------------------------------------------------------
128 // ----------------------------------------------------------------------------
132 #include "wx/cmdline.h"
133 #include "wx/datetime.h"
135 #if wxUSE_CMDLINE_PARSER
137 static void ShowCmdLine(const wxCmdLineParser
& parser
)
139 wxString s
= _T("Command line parsed successfully:\nInput files: ");
141 size_t count
= parser
.GetParamCount();
142 for ( size_t param
= 0; param
< count
; param
++ )
144 s
<< parser
.GetParam(param
) << ' ';
148 << _T("Verbose:\t") << (parser
.Found(_T("v")) ? _T("yes") : _T("no")) << '\n'
149 << _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("f"), &dVal
) )
162 s
<< _T("Double:\t") << dVal
<< '\n';
163 if ( parser
.Found(_T("d"), &dt
) )
164 s
<< _T("Date:\t") << dt
.FormatISODate() << '\n';
165 if ( parser
.Found(_T("project_name"), &strVal
) )
166 s
<< _T("Project:\t") << strVal
<< '\n';
171 #endif // wxUSE_CMDLINE_PARSER
173 static void TestCmdLineConvert()
175 static const wxChar
*cmdlines
[] =
178 _T("-a \"-bstring 1\" -c\"string 2\" \"string 3\""),
179 _T("literal \\\" and \"\""),
182 for ( size_t n
= 0; n
< WXSIZEOF(cmdlines
); n
++ )
184 const wxChar
*cmdline
= cmdlines
[n
];
185 wxPrintf(_T("Parsing: %s\n"), cmdline
);
186 wxArrayString args
= wxCmdLineParser::ConvertStringToArgs(cmdline
);
188 size_t count
= args
.GetCount();
189 wxPrintf(_T("\targc = %u\n"), count
);
190 for ( size_t arg
= 0; arg
< count
; arg
++ )
192 wxPrintf(_T("\targv[%u] = %s\n"), arg
, args
[arg
].c_str());
197 #endif // TEST_CMDLINE
199 // ----------------------------------------------------------------------------
201 // ----------------------------------------------------------------------------
208 static const wxChar
*ROOTDIR
= _T("/");
209 static const wxChar
*TESTDIR
= _T("/usr/local/share");
210 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
211 static const wxChar
*ROOTDIR
= _T("c:\\");
212 static const wxChar
*TESTDIR
= _T("d:\\");
214 #error "don't know where the root directory is"
217 static void TestDirEnumHelper(wxDir
& dir
,
218 int flags
= wxDIR_DEFAULT
,
219 const wxString
& filespec
= wxEmptyString
)
223 if ( !dir
.IsOpened() )
226 bool cont
= dir
.GetFirst(&filename
, filespec
, flags
);
229 wxPrintf(_T("\t%s\n"), filename
.c_str());
231 cont
= dir
.GetNext(&filename
);
234 wxPuts(wxEmptyString
);
239 static void TestDirEnum()
241 wxPuts(_T("*** Testing wxDir::GetFirst/GetNext ***"));
243 wxString cwd
= wxGetCwd();
244 if ( !wxDir::Exists(cwd
) )
246 wxPrintf(_T("ERROR: current directory '%s' doesn't exist?\n"), cwd
.c_str());
251 if ( !dir
.IsOpened() )
253 wxPrintf(_T("ERROR: failed to open current directory '%s'.\n"), cwd
.c_str());
257 wxPuts(_T("Enumerating everything in current directory:"));
258 TestDirEnumHelper(dir
);
260 wxPuts(_T("Enumerating really everything in current directory:"));
261 TestDirEnumHelper(dir
, wxDIR_DEFAULT
| wxDIR_DOTDOT
);
263 wxPuts(_T("Enumerating object files in current directory:"));
264 TestDirEnumHelper(dir
, wxDIR_DEFAULT
, _T("*.o*"));
266 wxPuts(_T("Enumerating directories in current directory:"));
267 TestDirEnumHelper(dir
, wxDIR_DIRS
);
269 wxPuts(_T("Enumerating files in current directory:"));
270 TestDirEnumHelper(dir
, wxDIR_FILES
);
272 wxPuts(_T("Enumerating files including hidden in current directory:"));
273 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
277 wxPuts(_T("Enumerating everything in root directory:"));
278 TestDirEnumHelper(dir
, wxDIR_DEFAULT
);
280 wxPuts(_T("Enumerating directories in root directory:"));
281 TestDirEnumHelper(dir
, wxDIR_DIRS
);
283 wxPuts(_T("Enumerating files in root directory:"));
284 TestDirEnumHelper(dir
, wxDIR_FILES
);
286 wxPuts(_T("Enumerating files including hidden in root directory:"));
287 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
289 wxPuts(_T("Enumerating files in non existing directory:"));
290 wxDir
dirNo(_T("nosuchdir"));
291 TestDirEnumHelper(dirNo
);
296 class DirPrintTraverser
: public wxDirTraverser
299 virtual wxDirTraverseResult
OnFile(const wxString
& WXUNUSED(filename
))
301 return wxDIR_CONTINUE
;
304 virtual wxDirTraverseResult
OnDir(const wxString
& dirname
)
306 wxString path
, name
, ext
;
307 wxSplitPath(dirname
, &path
, &name
, &ext
);
310 name
<< _T('.') << ext
;
313 for ( const wxChar
*p
= path
.c_str(); *p
; p
++ )
315 if ( wxIsPathSeparator(*p
) )
319 wxPrintf(_T("%s%s\n"), indent
.c_str(), name
.c_str());
321 return wxDIR_CONTINUE
;
325 static void TestDirTraverse()
327 wxPuts(_T("*** Testing wxDir::Traverse() ***"));
331 size_t n
= wxDir::GetAllFiles(TESTDIR
, &files
);
332 wxPrintf(_T("There are %u files under '%s'\n"), n
, TESTDIR
);
335 wxPrintf(_T("First one is '%s'\n"), files
[0u].c_str());
336 wxPrintf(_T(" last one is '%s'\n"), files
[n
- 1].c_str());
339 // enum again with custom traverser
340 wxPuts(_T("Now enumerating directories:"));
342 DirPrintTraverser traverser
;
343 dir
.Traverse(traverser
, wxEmptyString
, wxDIR_DIRS
| wxDIR_HIDDEN
);
348 static void TestDirExists()
350 wxPuts(_T("*** Testing wxDir::Exists() ***"));
352 static const wxChar
*dirnames
[] =
355 #if defined(__WXMSW__)
358 _T("\\\\share\\file"),
362 _T("c:\\autoexec.bat"),
363 #elif defined(__UNIX__)
372 for ( size_t n
= 0; n
< WXSIZEOF(dirnames
); n
++ )
374 wxPrintf(_T("%-40s: %s\n"),
376 wxDir::Exists(dirnames
[n
]) ? _T("exists")
377 : _T("doesn't exist"));
385 // ----------------------------------------------------------------------------
387 // ----------------------------------------------------------------------------
391 #include "wx/dynlib.h"
393 static void TestDllLoad()
395 #if defined(__WXMSW__)
396 static const wxChar
*LIB_NAME
= _T("kernel32.dll");
397 static const wxChar
*FUNC_NAME
= _T("lstrlenA");
398 #elif defined(__UNIX__)
399 // weird: using just libc.so does *not* work!
400 static const wxChar
*LIB_NAME
= _T("/lib/libc.so.6");
401 static const wxChar
*FUNC_NAME
= _T("strlen");
403 #error "don't know how to test wxDllLoader on this platform"
406 wxPuts(_T("*** testing basic wxDynamicLibrary functions ***\n"));
408 wxDynamicLibrary
lib(LIB_NAME
);
409 if ( !lib
.IsLoaded() )
411 wxPrintf(_T("ERROR: failed to load '%s'.\n"), LIB_NAME
);
415 typedef int (wxSTDCALL
*wxStrlenType
)(const char *);
416 wxStrlenType pfnStrlen
= (wxStrlenType
)lib
.GetSymbol(FUNC_NAME
);
419 wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"),
420 FUNC_NAME
, LIB_NAME
);
424 wxPrintf(_T("Calling %s dynamically loaded from %s "),
425 FUNC_NAME
, LIB_NAME
);
427 if ( pfnStrlen("foo") != 3 )
429 wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n"));
433 wxPuts(_T("... ok"));
438 static const wxChar
*FUNC_NAME_AW
= _T("lstrlen");
440 typedef int (wxSTDCALL
*wxStrlenTypeAorW
)(const wxChar
*);
442 pfnStrlenAorW
= (wxStrlenTypeAorW
)lib
.GetSymbolAorW(FUNC_NAME_AW
);
443 if ( !pfnStrlenAorW
)
445 wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"),
446 FUNC_NAME_AW
, LIB_NAME
);
450 if ( pfnStrlenAorW(_T("foobar")) != 6 )
452 wxPrintf(_T("ERROR: loaded function is not wxStrlen()!\n"));
459 #if defined(__WXMSW__) || defined(__UNIX__)
461 static void TestDllListLoaded()
463 wxPuts(_T("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
465 puts("\nLoaded modules:");
466 wxDynamicLibraryDetailsArray dlls
= wxDynamicLibrary::ListLoaded();
467 const size_t count
= dlls
.GetCount();
468 for ( size_t n
= 0; n
< count
; ++n
)
470 const wxDynamicLibraryDetails
& details
= dlls
[n
];
471 printf("%-45s", details
.GetPath().mb_str());
475 if ( details
.GetAddress(&addr
, &len
) )
477 printf(" %08lx:%08lx",
478 (unsigned long)addr
, (unsigned long)((char *)addr
+ len
));
481 printf(" %s\n", details
.GetVersion().mb_str());
487 #endif // TEST_DYNLIB
489 // ----------------------------------------------------------------------------
491 // ----------------------------------------------------------------------------
495 #include "wx/utils.h"
497 static wxString
MyGetEnv(const wxString
& var
)
500 if ( !wxGetEnv(var
, &val
) )
503 val
= wxString(_T('\'')) + val
+ _T('\'');
508 static void TestEnvironment()
510 const wxChar
*var
= _T("wxTestVar");
512 wxPuts(_T("*** testing environment access functions ***"));
514 wxPrintf(_T("Initially getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
515 wxSetEnv(var
, _T("value for wxTestVar"));
516 wxPrintf(_T("After wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
517 wxSetEnv(var
, _T("another value"));
518 wxPrintf(_T("After 2nd wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
520 wxPrintf(_T("After wxUnsetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
521 wxPrintf(_T("PATH = %s\n"), MyGetEnv(_T("PATH")).c_str());
524 #endif // TEST_ENVIRON
526 // ----------------------------------------------------------------------------
528 // ----------------------------------------------------------------------------
532 #include "wx/utils.h"
534 static void TestExecute()
536 wxPuts(_T("*** testing wxExecute ***"));
539 #define COMMAND "echo hi"
540 #define ASYNC_COMMAND "xclock"
541 #define SHELL_COMMAND "echo hi from shell"
542 #define REDIRECT_COMMAND COMMAND "cat -n Makefile"
543 #elif defined(__WXMSW__)
544 #define COMMAND "command.com /c echo hi"
545 #define ASYNC_COMMAND "notepad"
546 #define SHELL_COMMAND "echo hi"
547 #define REDIRECT_COMMAND COMMAND
549 #error "no command to exec"
552 wxPrintf(_T("Testing wxShell: "));
554 if ( wxShell(_T(SHELL_COMMAND
)) )
557 wxPuts(_T("ERROR."));
559 wxPrintf(_T("Testing wxExecute: "));
561 if ( wxExecute(_T(COMMAND
), wxEXEC_SYNC
) == 0 )
564 wxPuts(_T("ERROR."));
566 wxPrintf(_T("Testing async wxExecute: "));
568 int pid
= wxExecute(ASYNC_COMMAND
);
571 wxPuts(_T("Ok (command launched)."));
572 if ( wxKill(pid
) == -1 )
573 wxPuts("ERROR: failed to kill child process.");
576 wxPuts(_T("ERROR."));
578 wxPrintf(_T("Testing wxExecute with redirection:\n"));
579 wxArrayString output
;
580 if ( wxExecute(_T(REDIRECT_COMMAND
), output
) != 0 )
582 wxPuts(_T("ERROR."));
586 unsigned count
= output
.GetCount();
587 for ( unsigned n
= 0; n
< count
; n
++ )
589 wxPrintf("%04u:\t%s\n", n
, output
[n
]);
596 #endif // TEST_EXECUTE
598 // ----------------------------------------------------------------------------
600 // ----------------------------------------------------------------------------
605 #include "wx/ffile.h"
606 #include "wx/textfile.h"
608 static void TestFileRead()
610 wxPuts(_T("*** wxFile read test ***"));
612 wxFile
file(_T("testdata.fc"));
613 if ( file
.IsOpened() )
615 wxPrintf(_T("File length: %lu\n"), file
.Length());
617 wxPuts(_T("File dump:\n----------"));
619 static const size_t len
= 1024;
623 size_t nRead
= file
.Read(buf
, len
);
624 if ( nRead
== (size_t)wxInvalidOffset
)
626 wxPrintf(_T("Failed to read the file."));
630 fwrite(buf
, nRead
, 1, stdout
);
636 wxPuts(_T("----------"));
640 wxPrintf(_T("ERROR: can't open test file.\n"));
643 wxPuts(wxEmptyString
);
646 static void TestTextFileRead()
648 wxPuts(_T("*** wxTextFile read test ***"));
650 wxTextFile
file(_T("testdata.fc"));
653 wxPrintf(_T("Number of lines: %u\n"), file
.GetLineCount());
654 wxPrintf(_T("Last line: '%s'\n"), file
.GetLastLine().c_str());
658 wxPuts(_T("\nDumping the entire file:"));
659 for ( s
= file
.GetFirstLine(); !file
.Eof(); s
= file
.GetNextLine() )
661 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
663 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
665 wxPuts(_T("\nAnd now backwards:"));
666 for ( s
= file
.GetLastLine();
667 file
.GetCurrentLine() != 0;
668 s
= file
.GetPrevLine() )
670 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
672 wxPrintf(_T("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
676 wxPrintf(_T("ERROR: can't open '%s'\n"), file
.GetName());
679 wxPuts(wxEmptyString
);
682 static void TestFileCopy()
684 wxPuts(_T("*** Testing wxCopyFile ***"));
686 static const wxChar
*filename1
= _T("testdata.fc");
687 static const wxChar
*filename2
= _T("test2");
688 if ( !wxCopyFile(filename1
, filename2
) )
690 wxPuts(_T("ERROR: failed to copy file"));
694 wxFFile
f1(filename1
, _T("rb")),
695 f2(filename2
, _T("rb"));
697 if ( !f1
.IsOpened() || !f2
.IsOpened() )
699 wxPuts(_T("ERROR: failed to open file(s)"));
704 if ( !f1
.ReadAll(&s1
) || !f2
.ReadAll(&s2
) )
706 wxPuts(_T("ERROR: failed to read file(s)"));
710 if ( (s1
.length() != s2
.length()) ||
711 (memcmp(s1
.c_str(), s2
.c_str(), s1
.length()) != 0) )
713 wxPuts(_T("ERROR: copy error!"));
717 wxPuts(_T("File was copied ok."));
723 if ( !wxRemoveFile(filename2
) )
725 wxPuts(_T("ERROR: failed to remove the file"));
728 wxPuts(wxEmptyString
);
731 static void TestTempFile()
733 wxPuts(_T("*** wxTempFile test ***"));
736 if ( tmpFile
.Open(_T("test2")) && tmpFile
.Write(_T("the answer is 42")) )
738 if ( tmpFile
.Commit() )
739 wxPuts(_T("File committed."));
741 wxPuts(_T("ERROR: could't commit temp file."));
743 wxRemoveFile(_T("test2"));
746 wxPuts(wxEmptyString
);
751 // ----------------------------------------------------------------------------
753 // ----------------------------------------------------------------------------
757 #include "wx/confbase.h"
758 #include "wx/fileconf.h"
760 static const struct FileConfTestData
762 const wxChar
*name
; // value name
763 const wxChar
*value
; // the value from the file
766 { _T("value1"), _T("one") },
767 { _T("value2"), _T("two") },
768 { _T("novalue"), _T("default") },
771 static void TestFileConfRead()
773 wxPuts(_T("*** testing wxFileConfig loading/reading ***"));
775 wxFileConfig
fileconf(_T("test"), wxEmptyString
,
776 _T("testdata.fc"), wxEmptyString
,
777 wxCONFIG_USE_RELATIVE_PATH
);
779 // test simple reading
780 wxPuts(_T("\nReading config file:"));
781 wxString
defValue(_T("default")), value
;
782 for ( size_t n
= 0; n
< WXSIZEOF(fcTestData
); n
++ )
784 const FileConfTestData
& data
= fcTestData
[n
];
785 value
= fileconf
.Read(data
.name
, defValue
);
786 wxPrintf(_T("\t%s = %s "), data
.name
, value
.c_str());
787 if ( value
== data
.value
)
793 wxPrintf(_T("(ERROR: should be %s)\n"), data
.value
);
797 // test enumerating the entries
798 wxPuts(_T("\nEnumerating all root entries:"));
801 bool cont
= fileconf
.GetFirstEntry(name
, dummy
);
804 wxPrintf(_T("\t%s = %s\n"),
806 fileconf
.Read(name
.c_str(), _T("ERROR")).c_str());
808 cont
= fileconf
.GetNextEntry(name
, dummy
);
811 static const wxChar
*testEntry
= _T("TestEntry");
812 wxPrintf(_T("\nTesting deletion of newly created \"Test\" entry: "));
813 fileconf
.Write(testEntry
, _T("A value"));
814 fileconf
.DeleteEntry(testEntry
);
815 wxPrintf(fileconf
.HasEntry(testEntry
) ? _T("ERROR\n") : _T("ok\n"));
818 #endif // TEST_FILECONF
820 // ----------------------------------------------------------------------------
822 // ----------------------------------------------------------------------------
826 #include "wx/filename.h"
829 static void DumpFileName(const wxChar
*desc
, const wxFileName
& fn
)
833 wxString full
= fn
.GetFullPath();
835 wxString vol
, path
, name
, ext
;
836 wxFileName::SplitPath(full
, &vol
, &path
, &name
, &ext
);
838 wxPrintf(_T("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
839 full
.c_str(), vol
.c_str(), path
.c_str(), name
.c_str(), ext
.c_str());
841 wxFileName::SplitPath(full
, &path
, &name
, &ext
);
842 wxPrintf(_T("or\t\t-> path '%s', name '%s', ext '%s'\n"),
843 path
.c_str(), name
.c_str(), ext
.c_str());
845 wxPrintf(_T("path is also:\t'%s'\n"), fn
.GetPath().c_str());
846 wxPrintf(_T("with volume: \t'%s'\n"),
847 fn
.GetPath(wxPATH_GET_VOLUME
).c_str());
848 wxPrintf(_T("with separator:\t'%s'\n"),
849 fn
.GetPath(wxPATH_GET_SEPARATOR
).c_str());
850 wxPrintf(_T("with both: \t'%s'\n"),
851 fn
.GetPath(wxPATH_GET_SEPARATOR
| wxPATH_GET_VOLUME
).c_str());
853 wxPuts(_T("The directories in the path are:"));
854 wxArrayString dirs
= fn
.GetDirs();
855 size_t count
= dirs
.GetCount();
856 for ( size_t n
= 0; n
< count
; n
++ )
858 wxPrintf(_T("\t%u: %s\n"), n
, dirs
[n
].c_str());
863 static void TestFileNameTemp()
865 wxPuts(_T("*** testing wxFileName temp file creation ***"));
867 static const wxChar
*tmpprefixes
[] =
875 _T("/tmp/foo/bar"), // this one must be an error
879 for ( size_t n
= 0; n
< WXSIZEOF(tmpprefixes
); n
++ )
881 wxString path
= wxFileName::CreateTempFileName(tmpprefixes
[n
]);
884 // "error" is not in upper case because it may be ok
885 wxPrintf(_T("Prefix '%s'\t-> error\n"), tmpprefixes
[n
]);
889 wxPrintf(_T("Prefix '%s'\t-> temp file '%s'\n"),
890 tmpprefixes
[n
], path
.c_str());
892 if ( !wxRemoveFile(path
) )
894 wxLogWarning(_T("Failed to remove temp file '%s'"),
901 static void TestFileNameDirManip()
903 // TODO: test AppendDir(), RemoveDir(), ...
906 static void TestFileNameComparison()
911 static void TestFileNameOperations()
916 static void TestFileNameCwd()
921 #endif // TEST_FILENAME
923 // ----------------------------------------------------------------------------
924 // wxFileName time functions
925 // ----------------------------------------------------------------------------
929 #include "wx/filename.h"
930 #include "wx/datetime.h"
932 static void TestFileGetTimes()
934 wxFileName
fn(_T("testdata.fc"));
936 wxDateTime dtAccess
, dtMod
, dtCreate
;
937 if ( !fn
.GetTimes(&dtAccess
, &dtMod
, &dtCreate
) )
939 wxPrintf(_T("ERROR: GetTimes() failed.\n"));
943 static const wxChar
*fmt
= _T("%Y-%b-%d %H:%M:%S");
945 wxPrintf(_T("File times for '%s':\n"), fn
.GetFullPath().c_str());
946 wxPrintf(_T("Creation: \t%s\n"), dtCreate
.Format(fmt
).c_str());
947 wxPrintf(_T("Last read: \t%s\n"), dtAccess
.Format(fmt
).c_str());
948 wxPrintf(_T("Last write: \t%s\n"), dtMod
.Format(fmt
).c_str());
953 static void TestFileSetTimes()
955 wxFileName
fn(_T("testdata.fc"));
959 wxPrintf(_T("ERROR: Touch() failed.\n"));
964 #endif // TEST_FILETIME
966 // ----------------------------------------------------------------------------
968 // ----------------------------------------------------------------------------
973 #include "wx/utils.h" // for wxSetEnv
975 static wxLocale
gs_localeDefault(wxLANGUAGE_ENGLISH
);
977 // find the name of the language from its value
978 static const wxChar
*GetLangName(int lang
)
980 static const wxChar
*languageNames
[] =
990 _T("ARABIC_ALGERIA"),
991 _T("ARABIC_BAHRAIN"),
996 _T("ARABIC_LEBANON"),
998 _T("ARABIC_MOROCCO"),
1001 _T("ARABIC_SAUDI_ARABIA"),
1004 _T("ARABIC_TUNISIA"),
1011 _T("AZERI_CYRILLIC"),
1026 _T("CHINESE_SIMPLIFIED"),
1027 _T("CHINESE_TRADITIONAL"),
1028 _T("CHINESE_HONGKONG"),
1029 _T("CHINESE_MACAU"),
1030 _T("CHINESE_SINGAPORE"),
1031 _T("CHINESE_TAIWAN"),
1037 _T("DUTCH_BELGIAN"),
1041 _T("ENGLISH_AUSTRALIA"),
1042 _T("ENGLISH_BELIZE"),
1043 _T("ENGLISH_BOTSWANA"),
1044 _T("ENGLISH_CANADA"),
1045 _T("ENGLISH_CARIBBEAN"),
1046 _T("ENGLISH_DENMARK"),
1048 _T("ENGLISH_JAMAICA"),
1049 _T("ENGLISH_NEW_ZEALAND"),
1050 _T("ENGLISH_PHILIPPINES"),
1051 _T("ENGLISH_SOUTH_AFRICA"),
1052 _T("ENGLISH_TRINIDAD"),
1053 _T("ENGLISH_ZIMBABWE"),
1061 _T("FRENCH_BELGIAN"),
1062 _T("FRENCH_CANADIAN"),
1063 _T("FRENCH_LUXEMBOURG"),
1064 _T("FRENCH_MONACO"),
1070 _T("GERMAN_AUSTRIAN"),
1071 _T("GERMAN_BELGIUM"),
1072 _T("GERMAN_LIECHTENSTEIN"),
1073 _T("GERMAN_LUXEMBOURG"),
1091 _T("ITALIAN_SWISS"),
1096 _T("KASHMIRI_INDIA"),
1114 _T("MALAY_BRUNEI_DARUSSALAM"),
1115 _T("MALAY_MALAYSIA"),
1125 _T("NORWEGIAN_BOKMAL"),
1126 _T("NORWEGIAN_NYNORSK"),
1133 _T("PORTUGUESE_BRAZILIAN"),
1136 _T("RHAETO_ROMANCE"),
1139 _T("RUSSIAN_UKRAINE"),
1145 _T("SERBIAN_CYRILLIC"),
1146 _T("SERBIAN_LATIN"),
1147 _T("SERBO_CROATIAN"),
1158 _T("SPANISH_ARGENTINA"),
1159 _T("SPANISH_BOLIVIA"),
1160 _T("SPANISH_CHILE"),
1161 _T("SPANISH_COLOMBIA"),
1162 _T("SPANISH_COSTA_RICA"),
1163 _T("SPANISH_DOMINICAN_REPUBLIC"),
1164 _T("SPANISH_ECUADOR"),
1165 _T("SPANISH_EL_SALVADOR"),
1166 _T("SPANISH_GUATEMALA"),
1167 _T("SPANISH_HONDURAS"),
1168 _T("SPANISH_MEXICAN"),
1169 _T("SPANISH_MODERN"),
1170 _T("SPANISH_NICARAGUA"),
1171 _T("SPANISH_PANAMA"),
1172 _T("SPANISH_PARAGUAY"),
1174 _T("SPANISH_PUERTO_RICO"),
1175 _T("SPANISH_URUGUAY"),
1177 _T("SPANISH_VENEZUELA"),
1181 _T("SWEDISH_FINLAND"),
1199 _T("URDU_PAKISTAN"),
1201 _T("UZBEK_CYRILLIC"),
1214 if ( (size_t)lang
< WXSIZEOF(languageNames
) )
1215 return languageNames
[lang
];
1217 return _T("INVALID");
1220 static void TestDefaultLang()
1222 wxPuts(_T("*** Testing wxLocale::GetSystemLanguage ***"));
1224 static const wxChar
*langStrings
[] =
1226 NULL
, // system default
1233 _T("de_DE.iso88591"),
1235 _T("?"), // invalid lang spec
1236 _T("klingonese"), // I bet on some systems it does exist...
1239 wxPrintf(_T("The default system encoding is %s (%d)\n"),
1240 wxLocale::GetSystemEncodingName().c_str(),
1241 wxLocale::GetSystemEncoding());
1243 for ( size_t n
= 0; n
< WXSIZEOF(langStrings
); n
++ )
1245 const wxChar
*langStr
= langStrings
[n
];
1248 // FIXME: this doesn't do anything at all under Windows, we need
1249 // to create a new wxLocale!
1250 wxSetEnv(_T("LC_ALL"), langStr
);
1253 int lang
= gs_localeDefault
.GetSystemLanguage();
1254 wxPrintf(_T("Locale for '%s' is %s.\n"),
1255 langStr
? langStr
: _T("system default"), GetLangName(lang
));
1259 #endif // TEST_LOCALE
1261 // ----------------------------------------------------------------------------
1263 // ----------------------------------------------------------------------------
1267 #include "wx/mimetype.h"
1269 static void TestMimeEnum()
1271 wxPuts(_T("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1273 wxArrayString mimetypes
;
1275 size_t count
= wxTheMimeTypesManager
->EnumAllFileTypes(mimetypes
);
1277 wxPrintf(_T("*** All %u known filetypes: ***\n"), count
);
1282 for ( size_t n
= 0; n
< count
; n
++ )
1284 wxFileType
*filetype
=
1285 wxTheMimeTypesManager
->GetFileTypeFromMimeType(mimetypes
[n
]);
1288 wxPrintf(_T("nothing known about the filetype '%s'!\n"),
1289 mimetypes
[n
].c_str());
1293 filetype
->GetDescription(&desc
);
1294 filetype
->GetExtensions(exts
);
1296 filetype
->GetIcon(NULL
);
1299 for ( size_t e
= 0; e
< exts
.GetCount(); e
++ )
1302 extsAll
<< _T(", ");
1306 wxPrintf(_T("\t%s: %s (%s)\n"),
1307 mimetypes
[n
].c_str(), desc
.c_str(), extsAll
.c_str());
1310 wxPuts(wxEmptyString
);
1313 static void TestMimeOverride()
1315 wxPuts(_T("*** Testing wxMimeTypesManager additional files loading ***\n"));
1317 static const wxChar
*mailcap
= _T("/tmp/mailcap");
1318 static const wxChar
*mimetypes
= _T("/tmp/mime.types");
1320 if ( wxFile::Exists(mailcap
) )
1321 wxPrintf(_T("Loading mailcap from '%s': %s\n"),
1323 wxTheMimeTypesManager
->ReadMailcap(mailcap
) ? _T("ok") : _T("ERROR"));
1325 wxPrintf(_T("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1328 if ( wxFile::Exists(mimetypes
) )
1329 wxPrintf(_T("Loading mime.types from '%s': %s\n"),
1331 wxTheMimeTypesManager
->ReadMimeTypes(mimetypes
) ? _T("ok") : _T("ERROR"));
1333 wxPrintf(_T("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1336 wxPuts(wxEmptyString
);
1339 static void TestMimeFilename()
1341 wxPuts(_T("*** Testing MIME type from filename query ***\n"));
1343 static const wxChar
*filenames
[] =
1351 for ( size_t n
= 0; n
< WXSIZEOF(filenames
); n
++ )
1353 const wxString fname
= filenames
[n
];
1354 wxString ext
= fname
.AfterLast(_T('.'));
1355 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
1358 wxPrintf(_T("WARNING: extension '%s' is unknown.\n"), ext
.c_str());
1363 if ( !ft
->GetDescription(&desc
) )
1364 desc
= _T("<no description>");
1367 if ( !ft
->GetOpenCommand(&cmd
,
1368 wxFileType::MessageParameters(fname
, wxEmptyString
)) )
1369 cmd
= _T("<no command available>");
1371 cmd
= wxString(_T('"')) + cmd
+ _T('"');
1373 wxPrintf(_T("To open %s (%s) do %s.\n"),
1374 fname
.c_str(), desc
.c_str(), cmd
.c_str());
1380 wxPuts(wxEmptyString
);
1383 static void TestMimeAssociate()
1385 wxPuts(_T("*** Testing creation of filetype association ***\n"));
1387 wxFileTypeInfo
ftInfo(
1388 _T("application/x-xyz"),
1389 _T("xyzview '%s'"), // open cmd
1390 _T(""), // print cmd
1391 _T("XYZ File"), // description
1392 _T(".xyz"), // extensions
1393 wxNullPtr
// end of extensions
1395 ftInfo
.SetShortDesc(_T("XYZFile")); // used under Win32 only
1397 wxFileType
*ft
= wxTheMimeTypesManager
->Associate(ftInfo
);
1400 wxPuts(_T("ERROR: failed to create association!"));
1404 // TODO: read it back
1408 wxPuts(wxEmptyString
);
1413 // ----------------------------------------------------------------------------
1414 // module dependencies feature
1415 // ----------------------------------------------------------------------------
1419 #include "wx/module.h"
1421 class wxTestModule
: public wxModule
1424 virtual bool OnInit() { wxPrintf(_T("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1425 virtual void OnExit() { wxPrintf(_T("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1428 class wxTestModuleA
: public wxTestModule
1433 DECLARE_DYNAMIC_CLASS(wxTestModuleA
)
1436 class wxTestModuleB
: public wxTestModule
1441 DECLARE_DYNAMIC_CLASS(wxTestModuleB
)
1444 class wxTestModuleC
: public wxTestModule
1449 DECLARE_DYNAMIC_CLASS(wxTestModuleC
)
1452 class wxTestModuleD
: public wxTestModule
1457 DECLARE_DYNAMIC_CLASS(wxTestModuleD
)
1460 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC
, wxModule
)
1461 wxTestModuleC::wxTestModuleC()
1463 AddDependency(CLASSINFO(wxTestModuleD
));
1466 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA
, wxModule
)
1467 wxTestModuleA::wxTestModuleA()
1469 AddDependency(CLASSINFO(wxTestModuleB
));
1470 AddDependency(CLASSINFO(wxTestModuleD
));
1473 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD
, wxModule
)
1474 wxTestModuleD::wxTestModuleD()
1478 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB
, wxModule
)
1479 wxTestModuleB::wxTestModuleB()
1481 AddDependency(CLASSINFO(wxTestModuleD
));
1482 AddDependency(CLASSINFO(wxTestModuleC
));
1485 #endif // TEST_MODULE
1487 // ----------------------------------------------------------------------------
1488 // misc information functions
1489 // ----------------------------------------------------------------------------
1491 #ifdef TEST_INFO_FUNCTIONS
1493 #include "wx/utils.h"
1495 #if TEST_INTERACTIVE
1496 static void TestDiskInfo()
1498 wxPuts(_T("*** Testing wxGetDiskSpace() ***"));
1502 wxChar pathname
[128];
1503 wxPrintf(_T("\nEnter a directory name: "));
1504 if ( !wxFgets(pathname
, WXSIZEOF(pathname
), stdin
) )
1507 // kill the last '\n'
1508 pathname
[wxStrlen(pathname
) - 1] = 0;
1510 wxLongLong total
, free
;
1511 if ( !wxGetDiskSpace(pathname
, &total
, &free
) )
1513 wxPuts(_T("ERROR: wxGetDiskSpace failed."));
1517 wxPrintf(_T("%sKb total, %sKb free on '%s'.\n"),
1518 (total
/ 1024).ToString().c_str(),
1519 (free
/ 1024).ToString().c_str(),
1524 #endif // TEST_INTERACTIVE
1526 static void TestOsInfo()
1528 wxPuts(_T("*** Testing OS info functions ***\n"));
1531 wxGetOsVersion(&major
, &minor
);
1532 wxPrintf(_T("Running under: %s, version %d.%d\n"),
1533 wxGetOsDescription().c_str(), major
, minor
);
1535 wxPrintf(_T("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1537 wxPrintf(_T("Host name is %s (%s).\n"),
1538 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1540 wxPuts(wxEmptyString
);
1543 static void TestPlatformInfo()
1545 wxPuts(_T("*** Testing wxPlatformInfo functions ***\n"));
1547 // get this platform
1548 wxPlatformInfo plat
;
1550 wxPrintf(_T("Operating system family name is: %s\n"), plat
.GetOperatingSystemFamilyName().c_str());
1551 wxPrintf(_T("Operating system name is: %s\n"), plat
.GetOperatingSystemIdName().c_str());
1552 wxPrintf(_T("Port ID name is: %s\n"), plat
.GetPortIdName().c_str());
1553 wxPrintf(_T("Port ID short name is: %s\n"), plat
.GetPortIdShortName().c_str());
1554 wxPrintf(_T("Architecture is: %s\n"), plat
.GetArchName().c_str());
1555 wxPrintf(_T("Endianness is: %s\n"), plat
.GetEndiannessName().c_str());
1557 wxPuts(wxEmptyString
);
1560 static void TestUserInfo()
1562 wxPuts(_T("*** Testing user info functions ***\n"));
1564 wxPrintf(_T("User id is:\t%s\n"), wxGetUserId().c_str());
1565 wxPrintf(_T("User name is:\t%s\n"), wxGetUserName().c_str());
1566 wxPrintf(_T("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1567 wxPrintf(_T("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1569 wxPuts(wxEmptyString
);
1572 #endif // TEST_INFO_FUNCTIONS
1574 // ----------------------------------------------------------------------------
1576 // ----------------------------------------------------------------------------
1578 #ifdef TEST_PATHLIST
1581 #define CMD_IN_PATH _T("ls")
1583 #define CMD_IN_PATH _T("command.com")
1586 static void TestPathList()
1588 wxPuts(_T("*** Testing wxPathList ***\n"));
1590 wxPathList pathlist
;
1591 pathlist
.AddEnvList(_T("PATH"));
1592 wxString path
= pathlist
.FindValidPath(CMD_IN_PATH
);
1595 wxPrintf(_T("ERROR: command not found in the path.\n"));
1599 wxPrintf(_T("Command found in the path as '%s'.\n"), path
.c_str());
1603 #endif // TEST_PATHLIST
1605 // ----------------------------------------------------------------------------
1606 // regular expressions
1607 // ----------------------------------------------------------------------------
1611 #include "wx/regex.h"
1613 static void TestRegExInteractive()
1615 wxPuts(_T("*** Testing RE interactively ***"));
1619 wxChar pattern
[128];
1620 wxPrintf(_T("\nEnter a pattern: "));
1621 if ( !wxFgets(pattern
, WXSIZEOF(pattern
), stdin
) )
1624 // kill the last '\n'
1625 pattern
[wxStrlen(pattern
) - 1] = 0;
1628 if ( !re
.Compile(pattern
) )
1636 wxPrintf(_T("Enter text to match: "));
1637 if ( !wxFgets(text
, WXSIZEOF(text
), stdin
) )
1640 // kill the last '\n'
1641 text
[wxStrlen(text
) - 1] = 0;
1643 if ( !re
.Matches(text
) )
1645 wxPrintf(_T("No match.\n"));
1649 wxPrintf(_T("Pattern matches at '%s'\n"), re
.GetMatch(text
).c_str());
1652 for ( size_t n
= 1; ; n
++ )
1654 if ( !re
.GetMatch(&start
, &len
, n
) )
1659 wxPrintf(_T("Subexpr %u matched '%s'\n"),
1660 n
, wxString(text
+ start
, len
).c_str());
1667 #endif // TEST_REGEX
1669 // ----------------------------------------------------------------------------
1671 // ----------------------------------------------------------------------------
1674 NB: this stuff was taken from the glibc test suite and modified to build
1675 in wxWidgets: if I read the copyright below properly, this shouldn't
1681 #ifdef wxTEST_PRINTF
1682 // use our functions from wxchar.cpp
1686 // NB: do _not_ use ATTRIBUTE_PRINTF here, we have some invalid formats
1687 // in the tests below
1688 int wxPrintf( const wxChar
*format
, ... );
1689 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... );
1692 #include "wx/longlong.h"
1696 static void rfg1 (void);
1697 static void rfg2 (void);
1701 fmtchk (const wxChar
*fmt
)
1703 (void) wxPrintf(_T("%s:\t`"), fmt
);
1704 (void) wxPrintf(fmt
, 0x12);
1705 (void) wxPrintf(_T("'\n"));
1709 fmtst1chk (const wxChar
*fmt
)
1711 (void) wxPrintf(_T("%s:\t`"), fmt
);
1712 (void) wxPrintf(fmt
, 4, 0x12);
1713 (void) wxPrintf(_T("'\n"));
1717 fmtst2chk (const wxChar
*fmt
)
1719 (void) wxPrintf(_T("%s:\t`"), fmt
);
1720 (void) wxPrintf(fmt
, 4, 4, 0x12);
1721 (void) wxPrintf(_T("'\n"));
1724 /* This page is covered by the following copyright: */
1726 /* (C) Copyright C E Chew
1728 * Feel free to copy, use and distribute this software provided:
1730 * 1. you do not pretend that you wrote it
1731 * 2. you leave this copyright notice intact.
1735 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1742 /* Formatted Output Test
1744 * This exercises the output formatting code.
1747 wxChar
*PointerNull
= NULL
;
1754 wxChar
*prefix
= buf
;
1757 wxPuts(_T("\nFormatted output test"));
1758 wxPrintf(_T("prefix 6d 6o 6x 6X 6u\n"));
1759 wxStrcpy(prefix
, _T("%"));
1760 for (i
= 0; i
< 2; i
++) {
1761 for (j
= 0; j
< 2; j
++) {
1762 for (k
= 0; k
< 2; k
++) {
1763 for (l
= 0; l
< 2; l
++) {
1764 wxStrcpy(prefix
, _T("%"));
1765 if (i
== 0) wxStrcat(prefix
, _T("-"));
1766 if (j
== 0) wxStrcat(prefix
, _T("+"));
1767 if (k
== 0) wxStrcat(prefix
, _T("#"));
1768 if (l
== 0) wxStrcat(prefix
, _T("0"));
1769 wxPrintf(_T("%5s |"), prefix
);
1770 wxStrcpy(tp
, prefix
);
1771 wxStrcat(tp
, _T("6d |"));
1773 wxStrcpy(tp
, prefix
);
1774 wxStrcat(tp
, _T("6o |"));
1776 wxStrcpy(tp
, prefix
);
1777 wxStrcat(tp
, _T("6x |"));
1779 wxStrcpy(tp
, prefix
);
1780 wxStrcat(tp
, _T("6X |"));
1782 wxStrcpy(tp
, prefix
);
1783 wxStrcat(tp
, _T("6u |"));
1790 wxPrintf(_T("%10s\n"), PointerNull
);
1791 wxPrintf(_T("%-10s\n"), PointerNull
);
1794 static void TestPrintf()
1796 static wxChar shortstr
[] = _T("Hi, Z.");
1797 static wxChar longstr
[] = _T("Good morning, Doctor Chandra. This is Hal. \
1798 I am ready for my first lesson today.");
1800 wxString test_format
;
1804 fmtchk(_T("%4.4x"));
1805 fmtchk(_T("%04.4x"));
1806 fmtchk(_T("%4.3x"));
1807 fmtchk(_T("%04.3x"));
1809 fmtst1chk(_T("%.*x"));
1810 fmtst1chk(_T("%0*x"));
1811 fmtst2chk(_T("%*.*x"));
1812 fmtst2chk(_T("%0*.*x"));
1814 wxString bad_format
= _T("bad format:\t\"%b\"\n");
1815 wxPrintf(bad_format
.c_str());
1816 wxPrintf(_T("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL
);
1818 wxPrintf(_T("decimal negative:\t\"%d\"\n"), -2345);
1819 wxPrintf(_T("octal negative:\t\"%o\"\n"), -2345);
1820 wxPrintf(_T("hex negative:\t\"%x\"\n"), -2345);
1821 wxPrintf(_T("long decimal number:\t\"%ld\"\n"), -123456L);
1822 wxPrintf(_T("long octal negative:\t\"%lo\"\n"), -2345L);
1823 wxPrintf(_T("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
1824 wxPrintf(_T("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
1825 test_format
= _T("left-adjusted ZLDN:\t\"%-010ld\"\n");
1826 wxPrintf(test_format
.c_str(), -123456);
1827 wxPrintf(_T("space-padded LDN:\t\"%10ld\"\n"), -123456L);
1828 wxPrintf(_T("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
1830 test_format
= _T("zero-padded string:\t\"%010s\"\n");
1831 wxPrintf(test_format
.c_str(), shortstr
);
1832 test_format
= _T("left-adjusted Z string:\t\"%-010s\"\n");
1833 wxPrintf(test_format
.c_str(), shortstr
);
1834 wxPrintf(_T("space-padded string:\t\"%10s\"\n"), shortstr
);
1835 wxPrintf(_T("left-adjusted S string:\t\"%-10s\"\n"), shortstr
);
1836 wxPrintf(_T("null string:\t\"%s\"\n"), PointerNull
);
1837 wxPrintf(_T("limited string:\t\"%.22s\"\n"), longstr
);
1839 wxPrintf(_T("e-style >= 1:\t\"%e\"\n"), 12.34);
1840 wxPrintf(_T("e-style >= .1:\t\"%e\"\n"), 0.1234);
1841 wxPrintf(_T("e-style < .1:\t\"%e\"\n"), 0.001234);
1842 wxPrintf(_T("e-style big:\t\"%.60e\"\n"), 1e20
);
1843 wxPrintf(_T("e-style == .1:\t\"%e\"\n"), 0.1);
1844 wxPrintf(_T("f-style >= 1:\t\"%f\"\n"), 12.34);
1845 wxPrintf(_T("f-style >= .1:\t\"%f\"\n"), 0.1234);
1846 wxPrintf(_T("f-style < .1:\t\"%f\"\n"), 0.001234);
1847 wxPrintf(_T("g-style >= 1:\t\"%g\"\n"), 12.34);
1848 wxPrintf(_T("g-style >= .1:\t\"%g\"\n"), 0.1234);
1849 wxPrintf(_T("g-style < .1:\t\"%g\"\n"), 0.001234);
1850 wxPrintf(_T("g-style big:\t\"%.60g\"\n"), 1e20
);
1852 wxPrintf (_T(" %6.5f\n"), .099999999860301614);
1853 wxPrintf (_T(" %6.5f\n"), .1);
1854 wxPrintf (_T("x%5.4fx\n"), .5);
1856 wxPrintf (_T("%#03x\n"), 1);
1858 //wxPrintf (_T("something really insane: %.10000f\n"), 1.0);
1864 while (niter
-- != 0)
1865 wxPrintf (_T("%.17e\n"), d
/ 2);
1870 // Open Watcom cause compiler error here
1871 // Error! E173: col(24) floating-point constant too small to represent
1872 wxPrintf (_T("%15.5e\n"), 4.9406564584124654e-324);
1875 #define FORMAT _T("|%12.4f|%12.4e|%12.4g|\n")
1876 wxPrintf (FORMAT
, 0.0, 0.0, 0.0);
1877 wxPrintf (FORMAT
, 1.0, 1.0, 1.0);
1878 wxPrintf (FORMAT
, -1.0, -1.0, -1.0);
1879 wxPrintf (FORMAT
, 100.0, 100.0, 100.0);
1880 wxPrintf (FORMAT
, 1000.0, 1000.0, 1000.0);
1881 wxPrintf (FORMAT
, 10000.0, 10000.0, 10000.0);
1882 wxPrintf (FORMAT
, 12345.0, 12345.0, 12345.0);
1883 wxPrintf (FORMAT
, 100000.0, 100000.0, 100000.0);
1884 wxPrintf (FORMAT
, 123456.0, 123456.0, 123456.0);
1889 int rc
= wxSnprintf (buf
, WXSIZEOF(buf
), _T("%30s"), _T("foo"));
1891 wxPrintf(_T("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1892 rc
, WXSIZEOF(buf
), buf
);
1895 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1896 wxSnprintf(buf2
, WXSIZEOFbuf2
), "%.999999u", 10));
1902 wxPrintf (_T("%e should be 1.234568e+06\n"), 1234567.8);
1903 wxPrintf (_T("%f should be 1234567.800000\n"), 1234567.8);
1904 wxPrintf (_T("%g should be 1.23457e+06\n"), 1234567.8);
1905 wxPrintf (_T("%g should be 123.456\n"), 123.456);
1906 wxPrintf (_T("%g should be 1e+06\n"), 1000000.0);
1907 wxPrintf (_T("%g should be 10\n"), 10.0);
1908 wxPrintf (_T("%g should be 0.02\n"), 0.02);
1912 wxPrintf(_T("%.17f\n"),(1.0/x
/10.0+1.0)*x
-x
);
1918 wxSprintf(buf
,_T("%*s%*s%*s"),-1,_T("one"),-20,_T("two"),-30,_T("three"));
1920 result
|= wxStrcmp (buf
,
1921 _T("onetwo three "));
1923 wxPuts (result
!= 0 ? _T("Test failed!") : _T("Test ok."));
1930 wxSprintf(buf
, _T("%07") wxLongLongFmtSpec
_T("o"), wxLL(040000000000));
1932 // for some reason below line fails under Borland
1933 wxPrintf (_T("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf
);
1936 if (wxStrcmp (buf
, _T("40000000000")) != 0)
1939 wxPuts (_T("\tFAILED"));
1941 wxUnusedVar(result
);
1942 wxPuts (wxEmptyString
);
1944 #endif // wxLongLong_t
1946 wxPrintf (_T("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX
+ 2, UCHAR_MAX
+ 2);
1947 wxPrintf (_T("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX
+ 2, USHRT_MAX
+ 2);
1949 wxPuts (_T("--- Should be no further output. ---"));
1958 memset (bytes
, '\xff', sizeof bytes
);
1959 wxSprintf (buf
, _T("foo%hhn\n"), &bytes
[3]);
1960 if (bytes
[0] != '\xff' || bytes
[1] != '\xff' || bytes
[2] != '\xff'
1961 || bytes
[4] != '\xff' || bytes
[5] != '\xff' || bytes
[6] != '\xff')
1963 wxPuts (_T("%hhn overwrite more bytes"));
1968 wxPuts (_T("%hhn wrote incorrect value"));
1980 wxSprintf (buf
, _T("%5.s"), _T("xyz"));
1981 if (wxStrcmp (buf
, _T(" ")) != 0)
1982 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" "));
1983 wxSprintf (buf
, _T("%5.f"), 33.3);
1984 if (wxStrcmp (buf
, _T(" 33")) != 0)
1985 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 33"));
1986 wxSprintf (buf
, _T("%8.e"), 33.3e7
);
1987 if (wxStrcmp (buf
, _T(" 3e+08")) != 0)
1988 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3e+08"));
1989 wxSprintf (buf
, _T("%8.E"), 33.3e7
);
1990 if (wxStrcmp (buf
, _T(" 3E+08")) != 0)
1991 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3E+08"));
1992 wxSprintf (buf
, _T("%.g"), 33.3);
1993 if (wxStrcmp (buf
, _T("3e+01")) != 0)
1994 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3e+01"));
1995 wxSprintf (buf
, _T("%.G"), 33.3);
1996 if (wxStrcmp (buf
, _T("3E+01")) != 0)
1997 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3E+01"));
2005 wxString test_format
;
2008 wxSprintf (buf
, _T("%.*g"), prec
, 3.3);
2009 if (wxStrcmp (buf
, _T("3")) != 0)
2010 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3"));
2012 wxSprintf (buf
, _T("%.*G"), prec
, 3.3);
2013 if (wxStrcmp (buf
, _T("3")) != 0)
2014 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T("3"));
2016 wxSprintf (buf
, _T("%7.*G"), prec
, 3.33);
2017 if (wxStrcmp (buf
, _T(" 3")) != 0)
2018 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 3"));
2020 test_format
= _T("%04.*o");
2021 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2022 if (wxStrcmp (buf
, _T(" 041")) != 0)
2023 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 041"));
2025 test_format
= _T("%09.*u");
2026 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2027 if (wxStrcmp (buf
, _T(" 0000033")) != 0)
2028 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 0000033"));
2030 test_format
= _T("%04.*x");
2031 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2032 if (wxStrcmp (buf
, _T(" 021")) != 0)
2033 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 021"));
2035 test_format
= _T("%04.*X");
2036 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2037 if (wxStrcmp (buf
, _T(" 021")) != 0)
2038 wxPrintf (_T("got: '%s', expected: '%s'\n"), buf
, _T(" 021"));
2041 #endif // TEST_PRINTF
2043 // ----------------------------------------------------------------------------
2044 // registry and related stuff
2045 // ----------------------------------------------------------------------------
2047 // this is for MSW only
2050 #undef TEST_REGISTRY
2055 #include "wx/confbase.h"
2056 #include "wx/msw/regconf.h"
2059 static void TestRegConfWrite()
2061 wxConfig
*config
= new wxConfig(_T("myapp"));
2062 config
->SetPath(_T("/group1"));
2063 config
->Write(_T("entry1"), _T("foo"));
2064 config
->SetPath(_T("/group2"));
2065 config
->Write(_T("entry1"), _T("bar"));
2069 static void TestRegConfRead()
2071 wxConfig
*config
= new wxConfig(_T("myapp"));
2075 config
->SetPath(_T("/"));
2076 wxPuts(_T("Enumerating / subgroups:"));
2077 bool bCont
= config
->GetFirstGroup(str
, dummy
);
2081 bCont
= config
->GetNextGroup(str
, dummy
);
2085 #endif // TEST_REGCONF
2087 #ifdef TEST_REGISTRY
2089 #include "wx/msw/registry.h"
2091 // I chose this one because I liked its name, but it probably only exists under
2093 static const wxChar
*TESTKEY
=
2094 _T("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
2096 static void TestRegistryRead()
2098 wxPuts(_T("*** testing registry reading ***"));
2100 wxRegKey
key(TESTKEY
);
2101 wxPrintf(_T("The test key name is '%s'.\n"), key
.GetName().c_str());
2104 wxPuts(_T("ERROR: test key can't be opened, aborting test."));
2109 size_t nSubKeys
, nValues
;
2110 if ( key
.GetKeyInfo(&nSubKeys
, NULL
, &nValues
, NULL
) )
2112 wxPrintf(_T("It has %u subkeys and %u values.\n"), nSubKeys
, nValues
);
2115 wxPrintf(_T("Enumerating values:\n"));
2119 bool cont
= key
.GetFirstValue(value
, dummy
);
2122 wxPrintf(_T("Value '%s': type "), value
.c_str());
2123 switch ( key
.GetValueType(value
) )
2125 case wxRegKey::Type_None
: wxPrintf(_T("ERROR (none)")); break;
2126 case wxRegKey::Type_String
: wxPrintf(_T("SZ")); break;
2127 case wxRegKey::Type_Expand_String
: wxPrintf(_T("EXPAND_SZ")); break;
2128 case wxRegKey::Type_Binary
: wxPrintf(_T("BINARY")); break;
2129 case wxRegKey::Type_Dword
: wxPrintf(_T("DWORD")); break;
2130 case wxRegKey::Type_Multi_String
: wxPrintf(_T("MULTI_SZ")); break;
2131 default: wxPrintf(_T("other (unknown)")); break;
2134 wxPrintf(_T(", value = "));
2135 if ( key
.IsNumericValue(value
) )
2138 key
.QueryValue(value
, &val
);
2139 wxPrintf(_T("%ld"), val
);
2144 key
.QueryValue(value
, val
);
2145 wxPrintf(_T("'%s'"), val
.c_str());
2147 key
.QueryRawValue(value
, val
);
2148 wxPrintf(_T(" (raw value '%s')"), val
.c_str());
2153 cont
= key
.GetNextValue(value
, dummy
);
2157 static void TestRegistryAssociation()
2160 The second call to deleteself genertaes an error message, with a
2161 messagebox saying .flo is crucial to system operation, while the .ddf
2162 call also fails, but with no error message
2167 key
.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
2169 key
= _T("ddxf_auto_file") ;
2170 key
.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
2172 key
= _T("ddxf_auto_file") ;
2173 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2175 key
= _T("program,0") ;
2176 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2178 key
= _T("program \"%1\"") ;
2180 key
.SetName(_T("HKEY_CLASSES_ROOT\\.ddf") );
2182 key
.SetName(_T("HKEY_CLASSES_ROOT\\.flo") );
2184 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2186 key
.SetName(_T("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2190 #endif // TEST_REGISTRY
2192 // ----------------------------------------------------------------------------
2194 // ----------------------------------------------------------------------------
2196 #ifdef TEST_SCOPEGUARD
2198 #include "wx/scopeguard.h"
2200 static void function0() { puts("function0()"); }
2201 static void function1(int n
) { printf("function1(%d)\n", n
); }
2202 static void function2(double x
, char c
) { printf("function2(%g, %c)\n", x
, c
); }
2206 void method0() { printf("method0()\n"); }
2207 void method1(int n
) { printf("method1(%d)\n", n
); }
2208 void method2(double x
, char c
) { printf("method2(%g, %c)\n", x
, c
); }
2211 static void TestScopeGuard()
2213 wxON_BLOCK_EXIT0(function0
);
2214 wxON_BLOCK_EXIT1(function1
, 17);
2215 wxON_BLOCK_EXIT2(function2
, 3.14, 'p');
2218 wxON_BLOCK_EXIT_OBJ0(obj
, Object::method0
);
2219 wxON_BLOCK_EXIT_OBJ1(obj
, Object::method1
, 7);
2220 wxON_BLOCK_EXIT_OBJ2(obj
, Object::method2
, 2.71, 'e');
2222 wxScopeGuard dismissed
= wxMakeGuard(function0
);
2223 dismissed
.Dismiss();
2228 // ----------------------------------------------------------------------------
2230 // ----------------------------------------------------------------------------
2234 #include "wx/socket.h"
2235 #include "wx/protocol/protocol.h"
2236 #include "wx/protocol/http.h"
2238 static void TestSocketServer()
2240 wxPuts(_T("*** Testing wxSocketServer ***\n"));
2242 static const int PORT
= 3000;
2247 wxSocketServer
*server
= new wxSocketServer(addr
);
2248 if ( !server
->Ok() )
2250 wxPuts(_T("ERROR: failed to bind"));
2258 wxPrintf(_T("Server: waiting for connection on port %d...\n"), PORT
);
2260 wxSocketBase
*socket
= server
->Accept();
2263 wxPuts(_T("ERROR: wxSocketServer::Accept() failed."));
2267 wxPuts(_T("Server: got a client."));
2269 server
->SetTimeout(60); // 1 min
2272 while ( !close
&& socket
->IsConnected() )
2275 wxChar ch
= _T('\0');
2278 if ( socket
->Read(&ch
, sizeof(ch
)).Error() )
2280 // don't log error if the client just close the connection
2281 if ( socket
->IsConnected() )
2283 wxPuts(_T("ERROR: in wxSocket::Read."));
2303 wxPrintf(_T("Server: got '%s'.\n"), s
.c_str());
2304 if ( s
== _T("close") )
2306 wxPuts(_T("Closing connection"));
2310 else if ( s
== _T("quit") )
2315 wxPuts(_T("Shutting down the server"));
2317 else // not a special command
2319 socket
->Write(s
.MakeUpper().c_str(), s
.length());
2320 socket
->Write("\r\n", 2);
2321 wxPrintf(_T("Server: wrote '%s'.\n"), s
.c_str());
2327 wxPuts(_T("Server: lost a client unexpectedly."));
2333 // same as "delete server" but is consistent with GUI programs
2337 static void TestSocketClient()
2339 wxPuts(_T("*** Testing wxSocketClient ***\n"));
2341 static const wxChar
*hostname
= _T("www.wxwidgets.org");
2344 addr
.Hostname(hostname
);
2347 wxPrintf(_T("--- Attempting to connect to %s:80...\n"), hostname
);
2349 wxSocketClient client
;
2350 if ( !client
.Connect(addr
) )
2352 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2356 wxPrintf(_T("--- Connected to %s:%u...\n"),
2357 addr
.Hostname().c_str(), addr
.Service());
2361 // could use simply "GET" here I suppose
2363 wxString::Format(_T("GET http://%s/\r\n"), hostname
);
2364 client
.Write(cmdGet
, cmdGet
.length());
2365 wxPrintf(_T("--- Sent command '%s' to the server\n"),
2366 MakePrintable(cmdGet
).c_str());
2367 client
.Read(buf
, WXSIZEOF(buf
));
2368 wxPrintf(_T("--- Server replied:\n%s"), buf
);
2372 #endif // TEST_SOCKETS
2374 // ----------------------------------------------------------------------------
2376 // ----------------------------------------------------------------------------
2380 #include "wx/protocol/ftp.h"
2384 #define FTP_ANONYMOUS
2386 #ifdef FTP_ANONYMOUS
2387 static const wxChar
*directory
= _T("/pub");
2388 static const wxChar
*filename
= _T("welcome.msg");
2390 static const wxChar
*directory
= _T("/etc");
2391 static const wxChar
*filename
= _T("issue");
2394 static bool TestFtpConnect()
2396 wxPuts(_T("*** Testing FTP connect ***"));
2398 #ifdef FTP_ANONYMOUS
2399 static const wxChar
*hostname
= _T("ftp.wxwidgets.org");
2401 wxPrintf(_T("--- Attempting to connect to %s:21 anonymously...\n"), hostname
);
2402 #else // !FTP_ANONYMOUS
2403 static const wxChar
*hostname
= "localhost";
2406 wxFgets(user
, WXSIZEOF(user
), stdin
);
2407 user
[wxStrlen(user
) - 1] = '\0'; // chop off '\n'
2410 wxChar password
[256];
2411 wxPrintf(_T("Password for %s: "), password
);
2412 wxFgets(password
, WXSIZEOF(password
), stdin
);
2413 password
[wxStrlen(password
) - 1] = '\0'; // chop off '\n'
2414 ftp
.SetPassword(password
);
2416 wxPrintf(_T("--- Attempting to connect to %s:21 as %s...\n"), hostname
, user
);
2417 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2419 if ( !ftp
.Connect(hostname
) )
2421 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2427 wxPrintf(_T("--- Connected to %s, current directory is '%s'\n"),
2428 hostname
, ftp
.Pwd().c_str());
2435 // test (fixed?) wxFTP bug with wu-ftpd >= 2.6.0?
2436 static void TestFtpWuFtpd()
2439 static const wxChar
*hostname
= _T("ftp.eudora.com");
2440 if ( !ftp
.Connect(hostname
) )
2442 wxPrintf(_T("ERROR: failed to connect to %s\n"), hostname
);
2446 static const wxChar
*filename
= _T("eudora/pubs/draft-gellens-submit-09.txt");
2447 wxInputStream
*in
= ftp
.GetInputStream(filename
);
2450 wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename
);
2454 size_t size
= in
->GetSize();
2455 wxPrintf(_T("Reading file %s (%u bytes)..."), filename
, size
);
2457 wxChar
*data
= new wxChar
[size
];
2458 if ( !in
->Read(data
, size
) )
2460 wxPuts(_T("ERROR: read error"));
2464 wxPrintf(_T("Successfully retrieved the file.\n"));
2473 static void TestFtpList()
2475 wxPuts(_T("*** Testing wxFTP file listing ***\n"));
2478 if ( !ftp
.ChDir(directory
) )
2480 wxPrintf(_T("ERROR: failed to cd to %s\n"), directory
);
2483 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2485 // test NLIST and LIST
2486 wxArrayString files
;
2487 if ( !ftp
.GetFilesList(files
) )
2489 wxPuts(_T("ERROR: failed to get NLIST of files"));
2493 wxPrintf(_T("Brief list of files under '%s':\n"), ftp
.Pwd().c_str());
2494 size_t count
= files
.GetCount();
2495 for ( size_t n
= 0; n
< count
; n
++ )
2497 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2499 wxPuts(_T("End of the file list"));
2502 if ( !ftp
.GetDirList(files
) )
2504 wxPuts(_T("ERROR: failed to get LIST of files"));
2508 wxPrintf(_T("Detailed list of files under '%s':\n"), ftp
.Pwd().c_str());
2509 size_t count
= files
.GetCount();
2510 for ( size_t n
= 0; n
< count
; n
++ )
2512 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2514 wxPuts(_T("End of the file list"));
2517 if ( !ftp
.ChDir(_T("..")) )
2519 wxPuts(_T("ERROR: failed to cd to .."));
2522 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2525 static void TestFtpDownload()
2527 wxPuts(_T("*** Testing wxFTP download ***\n"));
2530 wxInputStream
*in
= ftp
.GetInputStream(filename
);
2533 wxPrintf(_T("ERROR: couldn't get input stream for %s\n"), filename
);
2537 size_t size
= in
->GetSize();
2538 wxPrintf(_T("Reading file %s (%u bytes)..."), filename
, size
);
2541 wxChar
*data
= new wxChar
[size
];
2542 if ( !in
->Read(data
, size
) )
2544 wxPuts(_T("ERROR: read error"));
2548 wxPrintf(_T("\nContents of %s:\n%s\n"), filename
, data
);
2556 static void TestFtpFileSize()
2558 wxPuts(_T("*** Testing FTP SIZE command ***"));
2560 if ( !ftp
.ChDir(directory
) )
2562 wxPrintf(_T("ERROR: failed to cd to %s\n"), directory
);
2565 wxPrintf(_T("Current directory is '%s'\n"), ftp
.Pwd().c_str());
2567 if ( ftp
.FileExists(filename
) )
2569 int size
= ftp
.GetFileSize(filename
);
2571 wxPrintf(_T("ERROR: couldn't get size of '%s'\n"), filename
);
2573 wxPrintf(_T("Size of '%s' is %d bytes.\n"), filename
, size
);
2577 wxPrintf(_T("ERROR: '%s' doesn't exist\n"), filename
);
2581 static void TestFtpMisc()
2583 wxPuts(_T("*** Testing miscellaneous wxFTP functions ***"));
2585 if ( ftp
.SendCommand(_T("STAT")) != '2' )
2587 wxPuts(_T("ERROR: STAT failed"));
2591 wxPrintf(_T("STAT returned:\n\n%s\n"), ftp
.GetLastResult().c_str());
2594 if ( ftp
.SendCommand(_T("HELP SITE")) != '2' )
2596 wxPuts(_T("ERROR: HELP SITE failed"));
2600 wxPrintf(_T("The list of site-specific commands:\n\n%s\n"),
2601 ftp
.GetLastResult().c_str());
2605 static void TestFtpInteractive()
2607 wxPuts(_T("\n*** Interactive wxFTP test ***"));
2613 wxPrintf(_T("Enter FTP command: "));
2614 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2617 // kill the last '\n'
2618 buf
[wxStrlen(buf
) - 1] = 0;
2620 // special handling of LIST and NLST as they require data connection
2621 wxString
start(buf
, 4);
2623 if ( start
== _T("LIST") || start
== _T("NLST") )
2626 if ( wxStrlen(buf
) > 4 )
2629 wxArrayString files
;
2630 if ( !ftp
.GetList(files
, wildcard
, start
== _T("LIST")) )
2632 wxPrintf(_T("ERROR: failed to get %s of files\n"), start
.c_str());
2636 wxPrintf(_T("--- %s of '%s' under '%s':\n"),
2637 start
.c_str(), wildcard
.c_str(), ftp
.Pwd().c_str());
2638 size_t count
= files
.GetCount();
2639 for ( size_t n
= 0; n
< count
; n
++ )
2641 wxPrintf(_T("\t%s\n"), files
[n
].c_str());
2643 wxPuts(_T("--- End of the file list"));
2648 wxChar ch
= ftp
.SendCommand(buf
);
2649 wxPrintf(_T("Command %s"), ch
? _T("succeeded") : _T("failed"));
2652 wxPrintf(_T(" (return code %c)"), ch
);
2655 wxPrintf(_T(", server reply:\n%s\n\n"), ftp
.GetLastResult().c_str());
2659 wxPuts(_T("\n*** done ***"));
2662 static void TestFtpUpload()
2664 wxPuts(_T("*** Testing wxFTP uploading ***\n"));
2667 static const wxChar
*file1
= _T("test1");
2668 static const wxChar
*file2
= _T("test2");
2669 wxOutputStream
*out
= ftp
.GetOutputStream(file1
);
2672 wxPrintf(_T("--- Uploading to %s ---\n"), file1
);
2673 out
->Write("First hello", 11);
2677 // send a command to check the remote file
2678 if ( ftp
.SendCommand(wxString(_T("STAT ")) + file1
) != '2' )
2680 wxPrintf(_T("ERROR: STAT %s failed\n"), file1
);
2684 wxPrintf(_T("STAT %s returned:\n\n%s\n"),
2685 file1
, ftp
.GetLastResult().c_str());
2688 out
= ftp
.GetOutputStream(file2
);
2691 wxPrintf(_T("--- Uploading to %s ---\n"), file1
);
2692 out
->Write("Second hello", 12);
2699 // ----------------------------------------------------------------------------
2701 // ----------------------------------------------------------------------------
2703 #ifdef TEST_STACKWALKER
2705 #if wxUSE_STACKWALKER
2707 #include "wx/stackwalk.h"
2709 class StackDump
: public wxStackWalker
2712 StackDump(const char *argv0
)
2713 : wxStackWalker(argv0
)
2717 virtual void Walk(size_t skip
= 1)
2719 wxPuts(_T("Stack dump:"));
2721 wxStackWalker::Walk(skip
);
2725 virtual void OnStackFrame(const wxStackFrame
& frame
)
2727 printf("[%2d] ", frame
.GetLevel());
2729 wxString name
= frame
.GetName();
2730 if ( !name
.empty() )
2732 printf("%-20.40s", name
.mb_str());
2736 printf("0x%08lx", (unsigned long)frame
.GetAddress());
2739 if ( frame
.HasSourceLocation() )
2742 frame
.GetFileName().mb_str(),
2749 for ( size_t n
= 0; frame
.GetParam(n
, &type
, &name
, &val
); n
++ )
2751 printf("\t%s %s = %s\n", type
.mb_str(), name
.mb_str(), val
.mb_str());
2756 static void TestStackWalk(const char *argv0
)
2758 wxPuts(_T("*** Testing wxStackWalker ***\n"));
2760 StackDump
dump(argv0
);
2764 #endif // wxUSE_STACKWALKER
2766 #endif // TEST_STACKWALKER
2768 // ----------------------------------------------------------------------------
2770 // ----------------------------------------------------------------------------
2772 #ifdef TEST_STDPATHS
2774 #include "wx/stdpaths.h"
2775 #include "wx/wxchar.h" // wxPrintf
2777 static void TestStandardPaths()
2779 wxPuts(_T("*** Testing wxStandardPaths ***\n"));
2781 wxTheApp
->SetAppName(_T("console"));
2783 wxStandardPathsBase
& stdp
= wxStandardPaths::Get();
2784 wxPrintf(_T("Config dir (sys):\t%s\n"), stdp
.GetConfigDir().c_str());
2785 wxPrintf(_T("Config dir (user):\t%s\n"), stdp
.GetUserConfigDir().c_str());
2786 wxPrintf(_T("Data dir (sys):\t\t%s\n"), stdp
.GetDataDir().c_str());
2787 wxPrintf(_T("Data dir (sys local):\t%s\n"), stdp
.GetLocalDataDir().c_str());
2788 wxPrintf(_T("Data dir (user):\t%s\n"), stdp
.GetUserDataDir().c_str());
2789 wxPrintf(_T("Data dir (user local):\t%s\n"), stdp
.GetUserLocalDataDir().c_str());
2790 wxPrintf(_T("Documents dir:\t\t%s\n"), stdp
.GetDocumentsDir().c_str());
2791 wxPrintf(_T("Executable path:\t%s\n"), stdp
.GetExecutablePath().c_str());
2792 wxPrintf(_T("Plugins dir:\t\t%s\n"), stdp
.GetPluginsDir().c_str());
2793 wxPrintf(_T("Resources dir:\t\t%s\n"), stdp
.GetResourcesDir().c_str());
2794 wxPrintf(_T("Localized res. dir:\t%s\n"),
2795 stdp
.GetLocalizedResourcesDir(_T("fr")).c_str());
2796 wxPrintf(_T("Message catalogs dir:\t%s\n"),
2797 stdp
.GetLocalizedResourcesDir
2800 wxStandardPaths::ResourceCat_Messages
2804 #endif // TEST_STDPATHS
2806 // ----------------------------------------------------------------------------
2808 // ----------------------------------------------------------------------------
2812 #include "wx/wfstream.h"
2813 #include "wx/mstream.h"
2815 static void TestFileStream()
2817 wxPuts(_T("*** Testing wxFileInputStream ***"));
2819 static const wxString filename
= _T("testdata.fs");
2821 wxFileOutputStream
fsOut(filename
);
2822 fsOut
.Write("foo", 3);
2826 wxFileInputStream
fsIn(filename
);
2827 wxPrintf(_T("File stream size: %u\n"), fsIn
.GetSize());
2828 while ( !fsIn
.Eof() )
2830 wxPutchar(fsIn
.GetC());
2834 if ( !wxRemoveFile(filename
) )
2836 wxPrintf(_T("ERROR: failed to remove the file '%s'.\n"), filename
.c_str());
2839 wxPuts(_T("\n*** wxFileInputStream test done ***"));
2842 static void TestMemoryStream()
2844 wxPuts(_T("*** Testing wxMemoryOutputStream ***"));
2846 wxMemoryOutputStream memOutStream
;
2847 wxPrintf(_T("Initially out stream offset: %lu\n"),
2848 (unsigned long)memOutStream
.TellO());
2850 for ( const wxChar
*p
= _T("Hello, stream!"); *p
; p
++ )
2852 memOutStream
.PutC(*p
);
2855 wxPrintf(_T("Final out stream offset: %lu\n"),
2856 (unsigned long)memOutStream
.TellO());
2858 wxPuts(_T("*** Testing wxMemoryInputStream ***"));
2861 size_t len
= memOutStream
.CopyTo(buf
, WXSIZEOF(buf
));
2863 wxMemoryInputStream
memInpStream(buf
, len
);
2864 wxPrintf(_T("Memory stream size: %u\n"), memInpStream
.GetSize());
2865 while ( !memInpStream
.Eof() )
2867 wxPutchar(memInpStream
.GetC());
2870 wxPuts(_T("\n*** wxMemoryInputStream test done ***"));
2873 #endif // TEST_STREAMS
2875 // ----------------------------------------------------------------------------
2877 // ----------------------------------------------------------------------------
2881 #include "wx/stopwatch.h"
2882 #include "wx/utils.h"
2884 static void TestStopWatch()
2886 wxPuts(_T("*** Testing wxStopWatch ***\n"));
2890 wxPrintf(_T("Initially paused, after 2 seconds time is..."));
2893 wxPrintf(_T("\t%ldms\n"), sw
.Time());
2895 wxPrintf(_T("Resuming stopwatch and sleeping 3 seconds..."));
2899 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2902 wxPrintf(_T("Pausing agan and sleeping 2 more seconds..."));
2905 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2908 wxPrintf(_T("Finally resuming and sleeping 2 more seconds..."));
2911 wxPrintf(_T("\telapsed time: %ldms\n"), sw
.Time());
2914 wxPuts(_T("\nChecking for 'backwards clock' bug..."));
2915 for ( size_t n
= 0; n
< 70; n
++ )
2919 for ( size_t m
= 0; m
< 100000; m
++ )
2921 if ( sw
.Time() < 0 || sw2
.Time() < 0 )
2923 wxPuts(_T("\ntime is negative - ERROR!"));
2931 wxPuts(_T(", ok."));
2934 #include "wx/timer.h"
2935 #include "wx/evtloop.h"
2939 wxPuts(_T("*** Testing wxTimer ***\n"));
2941 class MyTimer
: public wxTimer
2944 MyTimer() : wxTimer() { m_num
= 0; }
2946 virtual void Notify()
2948 wxPrintf(_T("%d"), m_num
++);
2953 wxPrintf(_T("... exiting the event loop"));
2956 wxEventLoop::GetActive()->Exit(0);
2957 wxPuts(_T(", ok."));
2970 timer1
.Start(100, true /* one shot */);
2972 timer1
.Start(100, true /* one shot */);
2980 #endif // TEST_TIMER
2982 // ----------------------------------------------------------------------------
2984 // ----------------------------------------------------------------------------
2988 #include "wx/vcard.h"
2990 static void DumpVObject(size_t level
, const wxVCardObject
& vcard
)
2993 wxVCardObject
*vcObj
= vcard
.GetFirstProp(&cookie
);
2996 wxPrintf(_T("%s%s"),
2997 wxString(_T('\t'), level
).c_str(),
2998 vcObj
->GetName().c_str());
3001 switch ( vcObj
->GetType() )
3003 case wxVCardObject::String
:
3004 case wxVCardObject::UString
:
3007 vcObj
->GetValue(&val
);
3008 value
<< _T('"') << val
<< _T('"');
3012 case wxVCardObject::Int
:
3015 vcObj
->GetValue(&i
);
3016 value
.Printf(_T("%u"), i
);
3020 case wxVCardObject::Long
:
3023 vcObj
->GetValue(&l
);
3024 value
.Printf(_T("%lu"), l
);
3028 case wxVCardObject::None
:
3031 case wxVCardObject::Object
:
3032 value
= _T("<node>");
3036 value
= _T("<unknown value type>");
3040 wxPrintf(_T(" = %s"), value
.c_str());
3043 DumpVObject(level
+ 1, *vcObj
);
3046 vcObj
= vcard
.GetNextProp(&cookie
);
3050 static void DumpVCardAddresses(const wxVCard
& vcard
)
3052 wxPuts(_T("\nShowing all addresses from vCard:\n"));
3056 wxVCardAddress
*addr
= vcard
.GetFirstAddress(&cookie
);
3060 int flags
= addr
->GetFlags();
3061 if ( flags
& wxVCardAddress::Domestic
)
3063 flagsStr
<< _T("domestic ");
3065 if ( flags
& wxVCardAddress::Intl
)
3067 flagsStr
<< _T("international ");
3069 if ( flags
& wxVCardAddress::Postal
)
3071 flagsStr
<< _T("postal ");
3073 if ( flags
& wxVCardAddress::Parcel
)
3075 flagsStr
<< _T("parcel ");
3077 if ( flags
& wxVCardAddress::Home
)
3079 flagsStr
<< _T("home ");
3081 if ( flags
& wxVCardAddress::Work
)
3083 flagsStr
<< _T("work ");
3086 wxPrintf(_T("Address %u:\n")
3088 "\tvalue = %s;%s;%s;%s;%s;%s;%s\n",
3091 addr
->GetPostOffice().c_str(),
3092 addr
->GetExtAddress().c_str(),
3093 addr
->GetStreet().c_str(),
3094 addr
->GetLocality().c_str(),
3095 addr
->GetRegion().c_str(),
3096 addr
->GetPostalCode().c_str(),
3097 addr
->GetCountry().c_str()
3101 addr
= vcard
.GetNextAddress(&cookie
);
3105 static void DumpVCardPhoneNumbers(const wxVCard
& vcard
)
3107 wxPuts(_T("\nShowing all phone numbers from vCard:\n"));
3111 wxVCardPhoneNumber
*phone
= vcard
.GetFirstPhoneNumber(&cookie
);
3115 int flags
= phone
->GetFlags();
3116 if ( flags
& wxVCardPhoneNumber::Voice
)
3118 flagsStr
<< _T("voice ");
3120 if ( flags
& wxVCardPhoneNumber::Fax
)
3122 flagsStr
<< _T("fax ");
3124 if ( flags
& wxVCardPhoneNumber::Cellular
)
3126 flagsStr
<< _T("cellular ");
3128 if ( flags
& wxVCardPhoneNumber::Modem
)
3130 flagsStr
<< _T("modem ");
3132 if ( flags
& wxVCardPhoneNumber::Home
)
3134 flagsStr
<< _T("home ");
3136 if ( flags
& wxVCardPhoneNumber::Work
)
3138 flagsStr
<< _T("work ");
3141 wxPrintf(_T("Phone number %u:\n")
3146 phone
->GetNumber().c_str()
3150 phone
= vcard
.GetNextPhoneNumber(&cookie
);
3154 static void TestVCardRead()
3156 wxPuts(_T("*** Testing wxVCard reading ***\n"));
3158 wxVCard
vcard(_T("vcard.vcf"));
3159 if ( !vcard
.IsOk() )
3161 wxPuts(_T("ERROR: couldn't load vCard."));
3165 // read individual vCard properties
3166 wxVCardObject
*vcObj
= vcard
.GetProperty("FN");
3170 vcObj
->GetValue(&value
);
3175 value
= _T("<none>");
3178 wxPrintf(_T("Full name retrieved directly: %s\n"), value
.c_str());
3181 if ( !vcard
.GetFullName(&value
) )
3183 value
= _T("<none>");
3186 wxPrintf(_T("Full name from wxVCard API: %s\n"), value
.c_str());
3188 // now show how to deal with multiply occurring properties
3189 DumpVCardAddresses(vcard
);
3190 DumpVCardPhoneNumbers(vcard
);
3192 // and finally show all
3193 wxPuts(_T("\nNow dumping the entire vCard:\n")
3194 "-----------------------------\n");
3196 DumpVObject(0, vcard
);
3200 static void TestVCardWrite()
3202 wxPuts(_T("*** Testing wxVCard writing ***\n"));
3205 if ( !vcard
.IsOk() )
3207 wxPuts(_T("ERROR: couldn't create vCard."));
3212 vcard
.SetName("Zeitlin", "Vadim");
3213 vcard
.SetFullName("Vadim Zeitlin");
3214 vcard
.SetOrganization("wxWidgets", "R&D");
3216 // just dump the vCard back
3217 wxPuts(_T("Entire vCard follows:\n"));
3218 wxPuts(vcard
.Write());
3222 #endif // TEST_VCARD
3224 // ----------------------------------------------------------------------------
3226 // ----------------------------------------------------------------------------
3228 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
3234 #include "wx/volume.h"
3236 static const wxChar
*volumeKinds
[] =
3242 _T("network volume"),
3246 static void TestFSVolume()
3248 wxPuts(_T("*** Testing wxFSVolume class ***"));
3250 wxArrayString volumes
= wxFSVolume::GetVolumes();
3251 size_t count
= volumes
.GetCount();
3255 wxPuts(_T("ERROR: no mounted volumes?"));
3259 wxPrintf(_T("%u mounted volumes found:\n"), count
);
3261 for ( size_t n
= 0; n
< count
; n
++ )
3263 wxFSVolume
vol(volumes
[n
]);
3266 wxPuts(_T("ERROR: couldn't create volume"));
3270 wxPrintf(_T("%u: %s (%s), %s, %s, %s\n"),
3272 vol
.GetDisplayName().c_str(),
3273 vol
.GetName().c_str(),
3274 volumeKinds
[vol
.GetKind()],
3275 vol
.IsWritable() ? _T("rw") : _T("ro"),
3276 vol
.GetFlags() & wxFS_VOL_REMOVABLE
? _T("removable")
3281 #endif // TEST_VOLUME
3283 // ----------------------------------------------------------------------------
3284 // wide char and Unicode support
3285 // ----------------------------------------------------------------------------
3289 #include "wx/strconv.h"
3290 #include "wx/fontenc.h"
3291 #include "wx/encconv.h"
3292 #include "wx/buffer.h"
3294 static const unsigned char utf8koi8r
[] =
3296 208, 157, 208, 181, 209, 129, 208, 186, 208, 176, 208, 183, 208, 176,
3297 208, 189, 208, 189, 208, 190, 32, 208, 191, 208, 190, 209, 128, 208,
3298 176, 208, 180, 208, 190, 208, 178, 208, 176, 208, 187, 32, 208, 188,
3299 208, 181, 208, 189, 209, 143, 32, 209, 129, 208, 178, 208, 190, 208,
3300 181, 208, 185, 32, 208, 186, 209, 128, 209, 131, 209, 130, 208, 181,
3301 208, 185, 209, 136, 208, 181, 208, 185, 32, 208, 189, 208, 190, 208,
3302 178, 208, 190, 209, 129, 209, 130, 209, 140, 209, 142, 0
3305 static const unsigned char utf8iso8859_1
[] =
3307 0x53, 0x79, 0x73, 0x74, 0xc3, 0xa8, 0x6d, 0x65, 0x73, 0x20, 0x49, 0x6e,
3308 0x74, 0xc3, 0xa9, 0x67, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x65,
3309 0x6e, 0x20, 0x4d, 0xc3, 0xa9, 0x63, 0x61, 0x6e, 0x69, 0x71, 0x75, 0x65,
3310 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65,
3311 0x74, 0x20, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x71, 0x75, 0x65, 0
3314 static const unsigned char utf8Invalid
[] =
3316 0x3c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3e, 0x32, 0x30, 0x30,
3317 0x32, 0xe5, 0xb9, 0xb4, 0x30, 0x39, 0xe6, 0x9c, 0x88, 0x32, 0x35, 0xe6,
3318 0x97, 0xa5, 0x20, 0x30, 0x37, 0xe6, 0x99, 0x82, 0x33, 0x39, 0xe5, 0x88,
3319 0x86, 0x35, 0x37, 0xe7, 0xa7, 0x92, 0x3c, 0x2f, 0x64, 0x69, 0x73, 0x70,
3323 static const struct Utf8Data
3325 const unsigned char *text
;
3327 const wxChar
*charset
;
3328 wxFontEncoding encoding
;
3331 { utf8Invalid
, WXSIZEOF(utf8Invalid
), _T("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3332 { utf8koi8r
, WXSIZEOF(utf8koi8r
), _T("koi8-r"), wxFONTENCODING_KOI8
},
3333 { utf8iso8859_1
, WXSIZEOF(utf8iso8859_1
), _T("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3336 static void TestUtf8()
3338 wxPuts(_T("*** Testing UTF8 support ***\n"));
3343 for ( size_t n
= 0; n
< WXSIZEOF(utf8data
); n
++ )
3345 const Utf8Data
& u8d
= utf8data
[n
];
3346 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)u8d
.text
,
3347 WXSIZEOF(wbuf
)) == (size_t)-1 )
3349 wxPuts(_T("ERROR: UTF-8 decoding failed."));
3353 wxCSConv
conv(u8d
.charset
);
3354 if ( conv
.WC2MB(buf
, wbuf
, WXSIZEOF(buf
)) == (size_t)-1 )
3356 wxPrintf(_T("ERROR: conversion to %s failed.\n"), u8d
.charset
);
3360 wxPrintf(_T("String in %s: %s\n"), u8d
.charset
, buf
);
3364 wxString
s(wxConvUTF8
.cMB2WC((const char *)u8d
.text
));
3366 s
= _T("<< conversion failed >>");
3367 wxPrintf(_T("String in current cset: %s\n"), s
.c_str());
3371 wxPuts(wxEmptyString
);
3374 static void TestEncodingConverter()
3376 wxPuts(_T("*** Testing wxEncodingConverter ***\n"));
3378 // using wxEncodingConverter should give the same result as above
3381 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)utf8koi8r
,
3382 WXSIZEOF(utf8koi8r
)) == (size_t)-1 )
3384 wxPuts(_T("ERROR: UTF-8 decoding failed."));
3388 wxEncodingConverter ec
;
3389 ec
.Init(wxFONTENCODING_UNICODE
, wxFONTENCODING_KOI8
);
3390 ec
.Convert(wbuf
, buf
);
3391 wxPrintf(_T("The same KOI8-R string using wxEC: %s\n"), buf
);
3394 wxPuts(wxEmptyString
);
3397 #endif // TEST_WCHAR
3399 // ----------------------------------------------------------------------------
3401 // ----------------------------------------------------------------------------
3405 #include "wx/filesys.h"
3406 #include "wx/fs_zip.h"
3407 #include "wx/zipstrm.h"
3409 static const wxChar
*TESTFILE_ZIP
= _T("testdata.zip");
3411 static void TestZipStreamRead()
3413 wxPuts(_T("*** Testing ZIP reading ***\n"));
3415 static const wxString filename
= _T("foo");
3416 wxZipInputStream
istr(TESTFILE_ZIP
, filename
);
3417 wxPrintf(_T("Archive size: %u\n"), istr
.GetSize());
3419 wxPrintf(_T("Dumping the file '%s':\n"), filename
.c_str());
3420 while ( !istr
.Eof() )
3422 wxPutchar(istr
.GetC());
3426 wxPuts(_T("\n----- done ------"));
3429 static void DumpZipDirectory(wxFileSystem
& fs
,
3430 const wxString
& dir
,
3431 const wxString
& indent
)
3433 wxString prefix
= wxString::Format(_T("%s#zip:%s"),
3434 TESTFILE_ZIP
, dir
.c_str());
3435 wxString wildcard
= prefix
+ _T("/*");
3437 wxString dirname
= fs
.FindFirst(wildcard
, wxDIR
);
3438 while ( !dirname
.empty() )
3440 if ( !dirname
.StartsWith(prefix
+ _T('/'), &dirname
) )
3442 wxPrintf(_T("ERROR: unexpected wxFileSystem::FindNext result\n"));
3447 wxPrintf(_T("%s%s\n"), indent
.c_str(), dirname
.c_str());
3449 DumpZipDirectory(fs
, dirname
,
3450 indent
+ wxString(_T(' '), 4));
3452 dirname
= fs
.FindNext();
3455 wxString filename
= fs
.FindFirst(wildcard
, wxFILE
);
3456 while ( !filename
.empty() )
3458 if ( !filename
.StartsWith(prefix
, &filename
) )
3460 wxPrintf(_T("ERROR: unexpected wxFileSystem::FindNext result\n"));
3465 wxPrintf(_T("%s%s\n"), indent
.c_str(), filename
.c_str());
3467 filename
= fs
.FindNext();
3471 static void TestZipFileSystem()
3473 wxPuts(_T("*** Testing ZIP file system ***\n"));
3475 wxFileSystem::AddHandler(new wxZipFSHandler
);
3477 wxPrintf(_T("Dumping all files in the archive %s:\n"), TESTFILE_ZIP
);
3479 DumpZipDirectory(fs
, _T(""), wxString(_T(' '), 4));
3484 // ----------------------------------------------------------------------------
3486 // ----------------------------------------------------------------------------
3488 #ifdef TEST_DATETIME
3490 #include "wx/math.h"
3491 #include "wx/datetime.h"
3493 // this test miscellaneous static wxDateTime functions
3497 static void TestTimeStatic()
3499 wxPuts(_T("\n*** wxDateTime static methods test ***"));
3501 // some info about the current date
3502 int year
= wxDateTime::GetCurrentYear();
3503 wxPrintf(_T("Current year %d is %sa leap one and has %d days.\n"),
3505 wxDateTime::IsLeapYear(year
) ? "" : "not ",
3506 wxDateTime::GetNumberOfDays(year
));
3508 wxDateTime::Month month
= wxDateTime::GetCurrentMonth();
3509 wxPrintf(_T("Current month is '%s' ('%s') and it has %d days\n"),
3510 wxDateTime::GetMonthName(month
, wxDateTime::Name_Abbr
).c_str(),
3511 wxDateTime::GetMonthName(month
).c_str(),
3512 wxDateTime::GetNumberOfDays(month
));
3515 // test time zones stuff
3516 static void TestTimeZones()
3518 wxPuts(_T("\n*** wxDateTime timezone test ***"));
3520 wxDateTime now
= wxDateTime::Now();
3522 wxPrintf(_T("Current GMT time:\t%s\n"), now
.Format(_T("%c"), wxDateTime::GMT0
).c_str());
3523 wxPrintf(_T("Unix epoch (GMT):\t%s\n"), wxDateTime((time_t)0).Format(_T("%c"), wxDateTime::GMT0
).c_str());
3524 wxPrintf(_T("Unix epoch (EST):\t%s\n"), wxDateTime((time_t)0).Format(_T("%c"), wxDateTime::EST
).c_str());
3525 wxPrintf(_T("Current time in Paris:\t%s\n"), now
.Format(_T("%c"), wxDateTime::CET
).c_str());
3526 wxPrintf(_T(" Moscow:\t%s\n"), now
.Format(_T("%c"), wxDateTime::MSK
).c_str());
3527 wxPrintf(_T(" New York:\t%s\n"), now
.Format(_T("%c"), wxDateTime::EST
).c_str());
3529 wxPrintf(_T("%s\n"), wxDateTime::Now().Format(_T("Our timezone is %Z")).c_str());
3531 wxDateTime::Tm tm
= now
.GetTm();
3532 if ( wxDateTime(tm
) != now
)
3534 wxPrintf(_T("ERROR: got %s instead of %s\n"),
3535 wxDateTime(tm
).Format().c_str(), now
.Format().c_str());
3539 // test some minimal support for the dates outside the standard range
3540 static void TestTimeRange()
3542 wxPuts(_T("\n*** wxDateTime out-of-standard-range dates test ***"));
3544 static const wxChar
*fmt
= _T("%d-%b-%Y %H:%M:%S");
3546 wxPrintf(_T("Unix epoch:\t%s\n"),
3547 wxDateTime(2440587.5).Format(fmt
).c_str());
3548 wxPrintf(_T("Feb 29, 0: \t%s\n"),
3549 wxDateTime(29, wxDateTime::Feb
, 0).Format(fmt
).c_str());
3550 wxPrintf(_T("JDN 0: \t%s\n"),
3551 wxDateTime(0.0).Format(fmt
).c_str());
3552 wxPrintf(_T("Jan 1, 1AD:\t%s\n"),
3553 wxDateTime(1, wxDateTime::Jan
, 1).Format(fmt
).c_str());
3554 wxPrintf(_T("May 29, 2099:\t%s\n"),
3555 wxDateTime(29, wxDateTime::May
, 2099).Format(fmt
).c_str());
3558 // test DST calculations
3559 static void TestTimeDST()
3561 wxPuts(_T("\n*** wxDateTime DST test ***"));
3563 wxPrintf(_T("DST is%s in effect now.\n\n"),
3564 wxDateTime::Now().IsDST() ? wxEmptyString
: _T(" not"));
3566 for ( int year
= 1990; year
< 2005; year
++ )
3568 wxPrintf(_T("DST period in Europe for year %d: from %s to %s\n"),
3570 wxDateTime::GetBeginDST(year
, wxDateTime::Country_EEC
).Format().c_str(),
3571 wxDateTime::GetEndDST(year
, wxDateTime::Country_EEC
).Format().c_str());
3577 #if TEST_INTERACTIVE
3579 static void TestDateTimeInteractive()
3581 wxPuts(_T("\n*** interactive wxDateTime tests ***"));
3587 wxPrintf(_T("Enter a date: "));
3588 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
3591 // kill the last '\n'
3592 buf
[wxStrlen(buf
) - 1] = 0;
3595 const wxChar
*p
= dt
.ParseDate(buf
);
3598 wxPrintf(_T("ERROR: failed to parse the date '%s'.\n"), buf
);
3604 wxPrintf(_T("WARNING: parsed only first %u characters.\n"), p
- buf
);
3607 wxPrintf(_T("%s: day %u, week of month %u/%u, week of year %u\n"),
3608 dt
.Format(_T("%b %d, %Y")).c_str(),
3610 dt
.GetWeekOfMonth(wxDateTime::Monday_First
),
3611 dt
.GetWeekOfMonth(wxDateTime::Sunday_First
),
3612 dt
.GetWeekOfYear(wxDateTime::Monday_First
));
3615 wxPuts(_T("\n*** done ***"));
3618 #endif // TEST_INTERACTIVE
3622 static void TestTimeMS()
3624 wxPuts(_T("*** testing millisecond-resolution support in wxDateTime ***"));
3626 wxDateTime dt1
= wxDateTime::Now(),
3627 dt2
= wxDateTime::UNow();
3629 wxPrintf(_T("Now = %s\n"), dt1
.Format(_T("%H:%M:%S:%l")).c_str());
3630 wxPrintf(_T("UNow = %s\n"), dt2
.Format(_T("%H:%M:%S:%l")).c_str());
3631 wxPrintf(_T("Dummy loop: "));
3632 for ( int i
= 0; i
< 6000; i
++ )
3634 //for ( int j = 0; j < 10; j++ )
3637 s
.Printf(_T("%g"), sqrt((float)i
));
3643 wxPuts(_T(", done"));
3646 dt2
= wxDateTime::UNow();
3647 wxPrintf(_T("UNow = %s\n"), dt2
.Format(_T("%H:%M:%S:%l")).c_str());
3649 wxPrintf(_T("Loop executed in %s ms\n"), (dt2
- dt1
).Format(_T("%l")).c_str());
3651 wxPuts(_T("\n*** done ***"));
3654 static void TestTimeHolidays()
3656 wxPuts(_T("\n*** testing wxDateTimeHolidayAuthority ***\n"));
3658 wxDateTime::Tm tm
= wxDateTime(29, wxDateTime::May
, 2000).GetTm();
3659 wxDateTime
dtStart(1, tm
.mon
, tm
.year
),
3660 dtEnd
= dtStart
.GetLastMonthDay();
3662 wxDateTimeArray hol
;
3663 wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart
, dtEnd
, hol
);
3665 const wxChar
*format
= _T("%d-%b-%Y (%a)");
3667 wxPrintf(_T("All holidays between %s and %s:\n"),
3668 dtStart
.Format(format
).c_str(), dtEnd
.Format(format
).c_str());
3670 size_t count
= hol
.GetCount();
3671 for ( size_t n
= 0; n
< count
; n
++ )
3673 wxPrintf(_T("\t%s\n"), hol
[n
].Format(format
).c_str());
3676 wxPuts(wxEmptyString
);
3679 static void TestTimeZoneBug()
3681 wxPuts(_T("\n*** testing for DST/timezone bug ***\n"));
3683 wxDateTime date
= wxDateTime(1, wxDateTime::Mar
, 2000);
3684 for ( int i
= 0; i
< 31; i
++ )
3686 wxPrintf(_T("Date %s: week day %s.\n"),
3687 date
.Format(_T("%d-%m-%Y")).c_str(),
3688 date
.GetWeekDayName(date
.GetWeekDay()).c_str());
3690 date
+= wxDateSpan::Day();
3693 wxPuts(wxEmptyString
);
3696 static void TestTimeSpanFormat()
3698 wxPuts(_T("\n*** wxTimeSpan tests ***"));
3700 static const wxChar
*formats
[] =
3702 _T("(default) %H:%M:%S"),
3703 _T("%E weeks and %D days"),
3704 _T("%l milliseconds"),
3705 _T("(with ms) %H:%M:%S:%l"),
3706 _T("100%% of minutes is %M"), // test "%%"
3707 _T("%D days and %H hours"),
3708 _T("or also %S seconds"),
3711 wxTimeSpan
ts1(1, 2, 3, 4),
3713 for ( size_t n
= 0; n
< WXSIZEOF(formats
); n
++ )
3715 wxPrintf(_T("ts1 = %s\tts2 = %s\n"),
3716 ts1
.Format(formats
[n
]).c_str(),
3717 ts2
.Format(formats
[n
]).c_str());
3720 wxPuts(wxEmptyString
);
3725 #endif // TEST_DATETIME
3727 // ----------------------------------------------------------------------------
3728 // wxTextInput/OutputStream
3729 // ----------------------------------------------------------------------------
3731 #ifdef TEST_TEXTSTREAM
3733 #include "wx/txtstrm.h"
3734 #include "wx/wfstream.h"
3736 static void TestTextInputStream()
3738 wxPuts(_T("\n*** wxTextInputStream test ***"));
3740 wxString filename
= _T("testdata.fc");
3741 wxFileInputStream
fsIn(filename
);
3744 wxPuts(_T("ERROR: couldn't open file."));
3748 wxTextInputStream
tis(fsIn
);
3753 const wxString s
= tis
.ReadLine();
3755 // line could be non empty if the last line of the file isn't
3756 // terminated with EOL
3757 if ( fsIn
.Eof() && s
.empty() )
3760 wxPrintf(_T("Line %d: %s\n"), line
++, s
.c_str());
3765 #endif // TEST_TEXTSTREAM
3767 // ----------------------------------------------------------------------------
3769 // ----------------------------------------------------------------------------
3773 #include "wx/thread.h"
3775 static size_t gs_counter
= (size_t)-1;
3776 static wxCriticalSection gs_critsect
;
3777 static wxSemaphore gs_cond
;
3779 class MyJoinableThread
: public wxThread
3782 MyJoinableThread(size_t n
) : wxThread(wxTHREAD_JOINABLE
)
3783 { m_n
= n
; Create(); }
3785 // thread execution starts here
3786 virtual ExitCode
Entry();
3792 wxThread::ExitCode
MyJoinableThread::Entry()
3794 unsigned long res
= 1;
3795 for ( size_t n
= 1; n
< m_n
; n
++ )
3799 // it's a loooong calculation :-)
3803 return (ExitCode
)res
;
3806 class MyDetachedThread
: public wxThread
3809 MyDetachedThread(size_t n
, wxChar ch
)
3813 m_cancelled
= false;
3818 // thread execution starts here
3819 virtual ExitCode
Entry();
3822 virtual void OnExit();
3825 size_t m_n
; // number of characters to write
3826 wxChar m_ch
; // character to write
3828 bool m_cancelled
; // false if we exit normally
3831 wxThread::ExitCode
MyDetachedThread::Entry()
3834 wxCriticalSectionLocker
lock(gs_critsect
);
3835 if ( gs_counter
== (size_t)-1 )
3841 for ( size_t n
= 0; n
< m_n
; n
++ )
3843 if ( TestDestroy() )
3853 wxThread::Sleep(100);
3859 void MyDetachedThread::OnExit()
3861 wxLogTrace(_T("thread"), _T("Thread %ld is in OnExit"), GetId());
3863 wxCriticalSectionLocker
lock(gs_critsect
);
3864 if ( !--gs_counter
&& !m_cancelled
)
3868 static void TestDetachedThreads()
3870 wxPuts(_T("\n*** Testing detached threads ***"));
3872 static const size_t nThreads
= 3;
3873 MyDetachedThread
*threads
[nThreads
];
3875 for ( n
= 0; n
< nThreads
; n
++ )
3877 threads
[n
] = new MyDetachedThread(10, 'A' + n
);
3880 threads
[0]->SetPriority(WXTHREAD_MIN_PRIORITY
);
3881 threads
[1]->SetPriority(WXTHREAD_MAX_PRIORITY
);
3883 for ( n
= 0; n
< nThreads
; n
++ )
3888 // wait until all threads terminate
3891 wxPuts(wxEmptyString
);
3894 static void TestJoinableThreads()
3896 wxPuts(_T("\n*** Testing a joinable thread (a loooong calculation...) ***"));
3898 // calc 10! in the background
3899 MyJoinableThread
thread(10);
3902 wxPrintf(_T("\nThread terminated with exit code %lu.\n"),
3903 (unsigned long)thread
.Wait());
3906 static void TestThreadSuspend()
3908 wxPuts(_T("\n*** Testing thread suspend/resume functions ***"));
3910 MyDetachedThread
*thread
= new MyDetachedThread(15, 'X');
3914 // this is for this demo only, in a real life program we'd use another
3915 // condition variable which would be signaled from wxThread::Entry() to
3916 // tell us that the thread really started running - but here just wait a
3917 // bit and hope that it will be enough (the problem is, of course, that
3918 // the thread might still not run when we call Pause() which will result
3920 wxThread::Sleep(300);
3922 for ( size_t n
= 0; n
< 3; n
++ )
3926 wxPuts(_T("\nThread suspended"));
3929 // don't sleep but resume immediately the first time
3930 wxThread::Sleep(300);
3932 wxPuts(_T("Going to resume the thread"));
3937 wxPuts(_T("Waiting until it terminates now"));
3939 // wait until the thread terminates
3942 wxPuts(wxEmptyString
);
3945 static void TestThreadDelete()
3947 // As above, using Sleep() is only for testing here - we must use some
3948 // synchronisation object instead to ensure that the thread is still
3949 // running when we delete it - deleting a detached thread which already
3950 // terminated will lead to a crash!
3952 wxPuts(_T("\n*** Testing thread delete function ***"));
3954 MyDetachedThread
*thread0
= new MyDetachedThread(30, 'W');
3958 wxPuts(_T("\nDeleted a thread which didn't start to run yet."));
3960 MyDetachedThread
*thread1
= new MyDetachedThread(30, 'Y');
3964 wxThread::Sleep(300);
3968 wxPuts(_T("\nDeleted a running thread."));
3970 MyDetachedThread
*thread2
= new MyDetachedThread(30, 'Z');
3974 wxThread::Sleep(300);
3980 wxPuts(_T("\nDeleted a sleeping thread."));
3982 MyJoinableThread
thread3(20);
3987 wxPuts(_T("\nDeleted a joinable thread."));
3989 MyJoinableThread
thread4(2);
3992 wxThread::Sleep(300);
3996 wxPuts(_T("\nDeleted a joinable thread which already terminated."));
3998 wxPuts(wxEmptyString
);
4001 class MyWaitingThread
: public wxThread
4004 MyWaitingThread( wxMutex
*mutex
, wxCondition
*condition
)
4007 m_condition
= condition
;
4012 virtual ExitCode
Entry()
4014 wxPrintf(_T("Thread %lu has started running.\n"), GetId());
4019 wxPrintf(_T("Thread %lu starts to wait...\n"), GetId());
4023 m_condition
->Wait();
4026 wxPrintf(_T("Thread %lu finished to wait, exiting.\n"), GetId());
4034 wxCondition
*m_condition
;
4037 static void TestThreadConditions()
4040 wxCondition
condition(mutex
);
4042 // otherwise its difficult to understand which log messages pertain to
4044 //wxLogTrace(_T("thread"), _T("Local condition var is %08x, gs_cond = %08x"),
4045 // condition.GetId(), gs_cond.GetId());
4047 // create and launch threads
4048 MyWaitingThread
*threads
[10];
4051 for ( n
= 0; n
< WXSIZEOF(threads
); n
++ )
4053 threads
[n
] = new MyWaitingThread( &mutex
, &condition
);
4056 for ( n
= 0; n
< WXSIZEOF(threads
); n
++ )
4061 // wait until all threads run
4062 wxPuts(_T("Main thread is waiting for the other threads to start"));
4065 size_t nRunning
= 0;
4066 while ( nRunning
< WXSIZEOF(threads
) )
4072 wxPrintf(_T("Main thread: %u already running\n"), nRunning
);
4076 wxPuts(_T("Main thread: all threads started up."));
4079 wxThread::Sleep(500);
4082 // now wake one of them up
4083 wxPrintf(_T("Main thread: about to signal the condition.\n"));
4088 wxThread::Sleep(200);
4090 // wake all the (remaining) threads up, so that they can exit
4091 wxPrintf(_T("Main thread: about to broadcast the condition.\n"));
4093 condition
.Broadcast();
4095 // give them time to terminate (dirty!)
4096 wxThread::Sleep(500);
4099 #include "wx/utils.h"
4101 class MyExecThread
: public wxThread
4104 MyExecThread(const wxString
& command
) : wxThread(wxTHREAD_JOINABLE
),
4110 virtual ExitCode
Entry()
4112 return (ExitCode
)wxExecute(m_command
, wxEXEC_SYNC
);
4119 static void TestThreadExec()
4121 wxPuts(_T("*** Testing wxExecute interaction with threads ***\n"));
4123 MyExecThread
thread(_T("true"));
4126 wxPrintf(_T("Main program exit code: %ld.\n"),
4127 wxExecute(_T("false"), wxEXEC_SYNC
));
4129 wxPrintf(_T("Thread exit code: %ld.\n"), (long)thread
.Wait());
4133 #include "wx/datetime.h"
4135 class MySemaphoreThread
: public wxThread
4138 MySemaphoreThread(int i
, wxSemaphore
*sem
)
4139 : wxThread(wxTHREAD_JOINABLE
),
4146 virtual ExitCode
Entry()
4148 wxPrintf(_T("%s: Thread #%d (%ld) starting to wait for semaphore...\n"),
4149 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4153 wxPrintf(_T("%s: Thread #%d (%ld) acquired the semaphore.\n"),
4154 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4158 wxPrintf(_T("%s: Thread #%d (%ld) releasing the semaphore.\n"),
4159 wxDateTime::Now().FormatTime().c_str(), m_i
, (long)GetId());
4171 WX_DEFINE_ARRAY_PTR(wxThread
*, ArrayThreads
);
4173 static void TestSemaphore()
4175 wxPuts(_T("*** Testing wxSemaphore class. ***"));
4177 static const int SEM_LIMIT
= 3;
4179 wxSemaphore
sem(SEM_LIMIT
, SEM_LIMIT
);
4180 ArrayThreads threads
;
4182 for ( int i
= 0; i
< 3*SEM_LIMIT
; i
++ )
4184 threads
.Add(new MySemaphoreThread(i
, &sem
));
4185 threads
.Last()->Run();
4188 for ( size_t n
= 0; n
< threads
.GetCount(); n
++ )
4195 #endif // TEST_THREADS
4197 // ----------------------------------------------------------------------------
4199 // ----------------------------------------------------------------------------
4201 #ifdef TEST_SNGLINST
4202 #include "wx/snglinst.h"
4203 #endif // TEST_SNGLINST
4205 int main(int argc
, char **argv
)
4208 wxChar
**wxArgv
= new wxChar
*[argc
+ 1];
4213 for (n
= 0; n
< argc
; n
++ )
4215 wxMB2WXbuf warg
= wxConvertMB2WX(argv
[n
]);
4216 wxArgv
[n
] = wxStrdup(warg
);
4221 #else // !wxUSE_UNICODE
4223 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
4225 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE
, "program");
4227 wxInitializer initializer
;
4230 fprintf(stderr
, "Failed to initialize the wxWidgets library, aborting.");
4235 #ifdef TEST_SNGLINST
4236 wxSingleInstanceChecker checker
;
4237 if ( checker
.Create(_T(".wxconsole.lock")) )
4239 if ( checker
.IsAnotherRunning() )
4241 wxPrintf(_T("Another instance of the program is running, exiting.\n"));
4246 // wait some time to give time to launch another instance
4247 wxPrintf(_T("Press \"Enter\" to continue..."));
4250 else // failed to create
4252 wxPrintf(_T("Failed to init wxSingleInstanceChecker.\n"));
4254 #endif // TEST_SNGLINST
4257 TestCmdLineConvert();
4259 #if wxUSE_CMDLINE_PARSER
4260 static const wxCmdLineEntryDesc cmdLineDesc
[] =
4262 { wxCMD_LINE_SWITCH
, "h", "help", "show this help message",
4263 wxCMD_LINE_VAL_NONE
, wxCMD_LINE_OPTION_HELP
},
4264 { wxCMD_LINE_SWITCH
, "v", "verbose", "be verbose" },
4265 { wxCMD_LINE_SWITCH
, "q", "quiet", "be quiet" },
4267 { wxCMD_LINE_OPTION
, "o", "output", "output file" },
4268 { wxCMD_LINE_OPTION
, "i", "input", "input dir" },
4269 { wxCMD_LINE_OPTION
, "s", "size", "output block size",
4270 wxCMD_LINE_VAL_NUMBER
},
4271 { wxCMD_LINE_OPTION
, "d", "date", "output file date",
4272 wxCMD_LINE_VAL_DATE
},
4273 { wxCMD_LINE_OPTION
, "f", "double", "output double",
4274 wxCMD_LINE_VAL_DOUBLE
},
4276 { wxCMD_LINE_PARAM
, NULL
, NULL
, "input file",
4277 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_MULTIPLE
},
4282 wxCmdLineParser
parser(cmdLineDesc
, argc
, wxArgv
);
4284 parser
.AddOption(_T("project_name"), _T(""), _T("full path to project file"),
4285 wxCMD_LINE_VAL_STRING
,
4286 wxCMD_LINE_OPTION_MANDATORY
| wxCMD_LINE_NEEDS_SEPARATOR
);
4288 switch ( parser
.Parse() )
4291 wxLogMessage(_T("Help was given, terminating."));
4295 ShowCmdLine(parser
);
4299 wxLogMessage(_T("Syntax error detected, aborting."));
4302 #endif // wxUSE_CMDLINE_PARSER
4304 #endif // TEST_CMDLINE
4316 TestDllListLoaded();
4317 #endif // TEST_DYNLIB
4321 #endif // TEST_ENVIRON
4325 #endif // TEST_EXECUTE
4327 #ifdef TEST_FILECONF
4329 #endif // TEST_FILECONF
4333 #endif // TEST_LOCALE
4336 wxPuts(_T("*** Testing wxLog ***"));
4339 for ( size_t n
= 0; n
< 8000; n
++ )
4341 s
<< (wxChar
)(_T('A') + (n
% 26));
4344 wxLogWarning(_T("The length of the string is %lu"),
4345 (unsigned long)s
.length());
4348 msg
.Printf(_T("A very very long message: '%s', the end!\n"), s
.c_str());
4350 // this one shouldn't be truncated
4353 // but this one will because log functions use fixed size buffer
4354 // (note that it doesn't need '\n' at the end neither - will be added
4356 wxLogMessage(_T("A very very long message 2: '%s', the end!"), s
.c_str());
4366 #ifdef TEST_FILENAME
4369 TestFileNameDirManip();
4370 TestFileNameComparison();
4371 TestFileNameOperations();
4372 #endif // TEST_FILENAME
4374 #ifdef TEST_FILETIME
4379 #endif // TEST_FILETIME
4382 wxLog::AddTraceMask(FTP_TRACE_MASK
);
4383 if ( TestFtpConnect() )
4393 #if TEST_INTERACTIVE
4394 TestFtpInteractive();
4397 //else: connecting to the FTP server failed
4405 //wxLog::AddTraceMask(_T("mime"));
4408 // TestMimeAssociate();
4412 #ifdef TEST_INFO_FUNCTIONS
4417 #if TEST_INTERACTIVE
4420 #endif // TEST_INFO_FUNCTIONS
4422 #ifdef TEST_PATHLIST
4424 #endif // TEST_PATHLIST
4428 #endif // TEST_PRINTF
4435 #endif // TEST_REGCONF
4437 #if defined TEST_REGEX && TEST_INTERACTIVE
4438 TestRegExInteractive();
4439 #endif // defined TEST_REGEX && TEST_INTERACTIVE
4441 #ifdef TEST_REGISTRY
4443 TestRegistryAssociation();
4444 #endif // TEST_REGISTRY
4449 #endif // TEST_SOCKETS
4456 #endif // TEST_STREAMS
4458 #ifdef TEST_TEXTSTREAM
4459 TestTextInputStream();
4460 #endif // TEST_TEXTSTREAM
4463 int nCPUs
= wxThread::GetCPUCount();
4464 wxPrintf(_T("This system has %d CPUs\n"), nCPUs
);
4466 wxThread::SetConcurrency(nCPUs
);
4468 TestJoinableThreads();
4471 TestJoinableThreads();
4472 TestDetachedThreads();
4473 TestThreadSuspend();
4475 TestThreadConditions();
4479 #endif // TEST_THREADS
4484 #endif // TEST_TIMER
4486 #ifdef TEST_DATETIME
4493 TestTimeSpanFormat();
4499 #if TEST_INTERACTIVE
4500 TestDateTimeInteractive();
4502 #endif // TEST_DATETIME
4504 #ifdef TEST_SCOPEGUARD
4508 #ifdef TEST_STACKWALKER
4509 #if wxUSE_STACKWALKER
4510 TestStackWalk(argv
[0]);
4512 #endif // TEST_STACKWALKER
4514 #ifdef TEST_STDPATHS
4515 TestStandardPaths();
4519 wxPuts(_T("Sleeping for 3 seconds... z-z-z-z-z..."));
4521 #endif // TEST_USLEEP
4526 #endif // TEST_VCARD
4530 #endif // TEST_VOLUME
4534 TestEncodingConverter();
4535 #endif // TEST_WCHAR
4538 TestZipStreamRead();
4539 TestZipFileSystem();
4544 for ( int n
= 0; n
< argc
; n
++ )
4549 #endif // wxUSE_UNICODE