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 // IMPORTANT NOTE FOR WXWIDGETS USERS:
13 // If you're a wxWidgets user and you're looking at this file to learn how to
14 // structure a wxWidgets console application, then you don't have much to learn.
15 // This application is used more for testing rather than as sample but
16 // basically the following simple block is enough for you to start your
17 // own console application:
20 int main(int argc, char **argv)
22 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
24 wxInitializer initializer;
27 fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
31 static const wxCmdLineEntryDesc cmdLineDesc[] =
33 { wxCMD_LINE_SWITCH, "h", "help", "show this help message",
34 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
35 // ... your other command line options here...
40 wxCmdLineParser parser(cmdLineDesc, argc, wxArgv);
41 switch ( parser.Parse() )
44 wxLogMessage(wxT("Help was given, terminating."));
48 // everything is ok; proceed
52 wxLogMessage(wxT("Syntax error detected, aborting."));
56 // do something useful here
63 // ============================================================================
65 // ============================================================================
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
75 #include "wx/string.h"
77 #include "wx/filename.h"
80 #include "wx/apptrait.h"
81 #include "wx/platinfo.h"
82 #include "wx/wxchar.h"
84 // without this pragma, the stupid compiler precompiles #defines below so that
85 // changing them doesn't "take place" later!
90 // ----------------------------------------------------------------------------
91 // conditional compilation
92 // ----------------------------------------------------------------------------
95 A note about all these conditional compilation macros: this file is used
96 both as a test suite for various non-GUI wxWidgets classes and as a
97 scratchpad for quick tests. So there are two compilation modes: if you
98 define TEST_ALL all tests are run, otherwise you may enable the individual
99 tests individually in the "#else" branch below.
102 // what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
103 // test, define it to 1 to do all tests.
109 #define TEST_DATETIME
114 #define TEST_FILECONF
115 #define TEST_FILENAME
116 #define TEST_FILETIME
118 #define TEST_INFO_FUNCTIONS
123 #define TEST_PATHLIST
127 #define TEST_REGISTRY
128 #define TEST_SCOPEGUARD
129 #define TEST_SNGLINST
130 // #define TEST_SOCKETS --FIXME! (RN)
131 #define TEST_STACKWALKER
132 #define TEST_STDPATHS
135 // #define TEST_VOLUME --FIXME! (RN)
137 #else // #if TEST_ALL
138 #define TEST_DATETIME
141 // some tests are interactive, define this to run them
142 #ifdef TEST_INTERACTIVE
143 #undef TEST_INTERACTIVE
145 #define TEST_INTERACTIVE 1
147 #define TEST_INTERACTIVE 1
150 // ============================================================================
152 // ============================================================================
154 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 #if defined(TEST_SOCKETS)
160 // replace TABs with \t and CRs with \n
161 static wxString
MakePrintable(const wxChar
*s
)
164 (void)str
.Replace(wxT("\t"), wxT("\\t"));
165 (void)str
.Replace(wxT("\n"), wxT("\\n"));
166 (void)str
.Replace(wxT("\r"), wxT("\\r"));
171 #endif // MakePrintable() is used
173 // ----------------------------------------------------------------------------
175 // ----------------------------------------------------------------------------
179 #include "wx/cmdline.h"
180 #include "wx/datetime.h"
182 #if wxUSE_CMDLINE_PARSER
184 static void ShowCmdLine(const wxCmdLineParser
& parser
)
186 wxString s
= wxT("Command line parsed successfully:\nInput files: ");
188 size_t count
= parser
.GetParamCount();
189 for ( size_t param
= 0; param
< count
; param
++ )
191 s
<< parser
.GetParam(param
) << ' ';
195 << wxT("Verbose:\t") << (parser
.Found(wxT("v")) ? wxT("yes") : wxT("no")) << '\n'
196 << wxT("Quiet:\t") << (parser
.Found(wxT("q")) ? wxT("yes") : wxT("no")) << '\n';
202 if ( parser
.Found(wxT("o"), &strVal
) )
203 s
<< wxT("Output file:\t") << strVal
<< '\n';
204 if ( parser
.Found(wxT("i"), &strVal
) )
205 s
<< wxT("Input dir:\t") << strVal
<< '\n';
206 if ( parser
.Found(wxT("s"), &lVal
) )
207 s
<< wxT("Size:\t") << lVal
<< '\n';
208 if ( parser
.Found(wxT("f"), &dVal
) )
209 s
<< wxT("Double:\t") << dVal
<< '\n';
210 if ( parser
.Found(wxT("d"), &dt
) )
211 s
<< wxT("Date:\t") << dt
.FormatISODate() << '\n';
212 if ( parser
.Found(wxT("project_name"), &strVal
) )
213 s
<< wxT("Project:\t") << strVal
<< '\n';
218 #endif // wxUSE_CMDLINE_PARSER
220 static void TestCmdLineConvert()
222 static const wxChar
*cmdlines
[] =
225 wxT("-a \"-bstring 1\" -c\"string 2\" \"string 3\""),
226 wxT("literal \\\" and \"\""),
229 for ( size_t n
= 0; n
< WXSIZEOF(cmdlines
); n
++ )
231 const wxChar
*cmdline
= cmdlines
[n
];
232 wxPrintf(wxT("Parsing: %s\n"), cmdline
);
233 wxArrayString args
= wxCmdLineParser::ConvertStringToArgs(cmdline
);
235 size_t count
= args
.GetCount();
236 wxPrintf(wxT("\targc = %u\n"), count
);
237 for ( size_t arg
= 0; arg
< count
; arg
++ )
239 wxPrintf(wxT("\targv[%u] = %s\n"), arg
, args
[arg
].c_str());
244 #endif // TEST_CMDLINE
246 // ----------------------------------------------------------------------------
248 // ----------------------------------------------------------------------------
255 static const wxChar
*ROOTDIR
= wxT("/");
256 static const wxChar
*TESTDIR
= wxT("/usr/local/share");
257 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
258 static const wxChar
*ROOTDIR
= wxT("c:\\");
259 static const wxChar
*TESTDIR
= wxT("d:\\");
261 #error "don't know where the root directory is"
264 static void TestDirEnumHelper(wxDir
& dir
,
265 int flags
= wxDIR_DEFAULT
,
266 const wxString
& filespec
= wxEmptyString
)
270 if ( !dir
.IsOpened() )
273 bool cont
= dir
.GetFirst(&filename
, filespec
, flags
);
276 wxPrintf(wxT("\t%s\n"), filename
.c_str());
278 cont
= dir
.GetNext(&filename
);
281 wxPuts(wxEmptyString
);
286 static void TestDirEnum()
288 wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
290 wxString cwd
= wxGetCwd();
291 if ( !wxDir::Exists(cwd
) )
293 wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd
.c_str());
298 if ( !dir
.IsOpened() )
300 wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd
.c_str());
304 wxPuts(wxT("Enumerating everything in current directory:"));
305 TestDirEnumHelper(dir
);
307 wxPuts(wxT("Enumerating really everything in current directory:"));
308 TestDirEnumHelper(dir
, wxDIR_DEFAULT
| wxDIR_DOTDOT
);
310 wxPuts(wxT("Enumerating object files in current directory:"));
311 TestDirEnumHelper(dir
, wxDIR_DEFAULT
, wxT("*.o*"));
313 wxPuts(wxT("Enumerating directories in current directory:"));
314 TestDirEnumHelper(dir
, wxDIR_DIRS
);
316 wxPuts(wxT("Enumerating files in current directory:"));
317 TestDirEnumHelper(dir
, wxDIR_FILES
);
319 wxPuts(wxT("Enumerating files including hidden in current directory:"));
320 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
324 wxPuts(wxT("Enumerating everything in root directory:"));
325 TestDirEnumHelper(dir
, wxDIR_DEFAULT
);
327 wxPuts(wxT("Enumerating directories in root directory:"));
328 TestDirEnumHelper(dir
, wxDIR_DIRS
);
330 wxPuts(wxT("Enumerating files in root directory:"));
331 TestDirEnumHelper(dir
, wxDIR_FILES
);
333 wxPuts(wxT("Enumerating files including hidden in root directory:"));
334 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
336 wxPuts(wxT("Enumerating files in non existing directory:"));
337 wxDir
dirNo(wxT("nosuchdir"));
338 TestDirEnumHelper(dirNo
);
343 class DirPrintTraverser
: public wxDirTraverser
346 virtual wxDirTraverseResult
OnFile(const wxString
& WXUNUSED(filename
))
348 return wxDIR_CONTINUE
;
351 virtual wxDirTraverseResult
OnDir(const wxString
& dirname
)
353 wxString path
, name
, ext
;
354 wxFileName::SplitPath(dirname
, &path
, &name
, &ext
);
357 name
<< wxT('.') << ext
;
360 for ( const wxChar
*p
= path
.c_str(); *p
; p
++ )
362 if ( wxIsPathSeparator(*p
) )
366 wxPrintf(wxT("%s%s\n"), indent
.c_str(), name
.c_str());
368 return wxDIR_CONTINUE
;
372 static void TestDirTraverse()
374 wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
378 size_t n
= wxDir::GetAllFiles(TESTDIR
, &files
);
379 wxPrintf(wxT("There are %u files under '%s'\n"), n
, TESTDIR
);
382 wxPrintf(wxT("First one is '%s'\n"), files
[0u].c_str());
383 wxPrintf(wxT(" last one is '%s'\n"), files
[n
- 1].c_str());
386 // enum again with custom traverser
387 wxPuts(wxT("Now enumerating directories:"));
389 DirPrintTraverser traverser
;
390 dir
.Traverse(traverser
, wxEmptyString
, wxDIR_DIRS
| wxDIR_HIDDEN
);
395 static void TestDirExists()
397 wxPuts(wxT("*** Testing wxDir::Exists() ***"));
399 static const wxChar
*dirnames
[] =
402 #if defined(__WXMSW__)
405 wxT("\\\\share\\file"),
409 wxT("c:\\autoexec.bat"),
410 #elif defined(__UNIX__)
419 for ( size_t n
= 0; n
< WXSIZEOF(dirnames
); n
++ )
421 wxPrintf(wxT("%-40s: %s\n"),
423 wxDir::Exists(dirnames
[n
]) ? wxT("exists")
424 : wxT("doesn't exist"));
432 // ----------------------------------------------------------------------------
434 // ----------------------------------------------------------------------------
438 #include "wx/dynlib.h"
440 static void TestDllLoad()
442 #if defined(__WXMSW__)
443 static const wxChar
*LIB_NAME
= wxT("kernel32.dll");
444 static const wxChar
*FUNC_NAME
= wxT("lstrlenA");
445 #elif defined(__UNIX__)
446 // weird: using just libc.so does *not* work!
447 static const wxChar
*LIB_NAME
= wxT("/lib/libc.so.6");
448 static const wxChar
*FUNC_NAME
= wxT("strlen");
450 #error "don't know how to test wxDllLoader on this platform"
453 wxPuts(wxT("*** testing basic wxDynamicLibrary functions ***\n"));
455 wxDynamicLibrary
lib(LIB_NAME
);
456 if ( !lib
.IsLoaded() )
458 wxPrintf(wxT("ERROR: failed to load '%s'.\n"), LIB_NAME
);
462 typedef int (wxSTDCALL
*wxStrlenType
)(const char *);
463 wxStrlenType pfnStrlen
= (wxStrlenType
)lib
.GetSymbol(FUNC_NAME
);
466 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
467 FUNC_NAME
, LIB_NAME
);
471 wxPrintf(wxT("Calling %s dynamically loaded from %s "),
472 FUNC_NAME
, LIB_NAME
);
474 if ( pfnStrlen("foo") != 3 )
476 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
480 wxPuts(wxT("... ok"));
485 static const wxChar
*FUNC_NAME_AW
= wxT("lstrlen");
487 typedef int (wxSTDCALL
*wxStrlenTypeAorW
)(const wxChar
*);
489 pfnStrlenAorW
= (wxStrlenTypeAorW
)lib
.GetSymbolAorW(FUNC_NAME_AW
);
490 if ( !pfnStrlenAorW
)
492 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
493 FUNC_NAME_AW
, LIB_NAME
);
497 if ( pfnStrlenAorW(wxT("foobar")) != 6 )
499 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
506 #if defined(__WXMSW__) || defined(__UNIX__)
508 static void TestDllListLoaded()
510 wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
512 puts("\nLoaded modules:");
513 wxDynamicLibraryDetailsArray dlls
= wxDynamicLibrary::ListLoaded();
514 const size_t count
= dlls
.GetCount();
515 for ( size_t n
= 0; n
< count
; ++n
)
517 const wxDynamicLibraryDetails
& details
= dlls
[n
];
518 printf("%-45s", (const char *)details
.GetPath().mb_str());
520 void *addr
wxDUMMY_INITIALIZE(NULL
);
521 size_t len
wxDUMMY_INITIALIZE(0);
522 if ( details
.GetAddress(&addr
, &len
) )
524 printf(" %08lx:%08lx",
525 (unsigned long)addr
, (unsigned long)((char *)addr
+ len
));
528 printf(" %s\n", (const char *)details
.GetVersion().mb_str());
534 #endif // TEST_DYNLIB
536 // ----------------------------------------------------------------------------
538 // ----------------------------------------------------------------------------
542 #include "wx/utils.h"
544 static wxString
MyGetEnv(const wxString
& var
)
547 if ( !wxGetEnv(var
, &val
) )
548 val
= wxT("<empty>");
550 val
= wxString(wxT('\'')) + val
+ wxT('\'');
555 static void TestEnvironment()
557 const wxChar
*var
= wxT("wxTestVar");
559 wxPuts(wxT("*** testing environment access functions ***"));
561 wxPrintf(wxT("Initially getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
562 wxSetEnv(var
, wxT("value for wxTestVar"));
563 wxPrintf(wxT("After wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
564 wxSetEnv(var
, wxT("another value"));
565 wxPrintf(wxT("After 2nd wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
567 wxPrintf(wxT("After wxUnsetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
568 wxPrintf(wxT("PATH = %s\n"), MyGetEnv(wxT("PATH")).c_str());
571 #endif // TEST_ENVIRON
573 // ----------------------------------------------------------------------------
575 // ----------------------------------------------------------------------------
580 #include "wx/ffile.h"
581 #include "wx/textfile.h"
583 static void TestFileRead()
585 wxPuts(wxT("*** wxFile read test ***"));
587 wxFile
file(wxT("testdata.fc"));
588 if ( file
.IsOpened() )
590 wxPrintf(wxT("File length: %lu\n"), file
.Length());
592 wxPuts(wxT("File dump:\n----------"));
594 static const size_t len
= 1024;
598 size_t nRead
= file
.Read(buf
, len
);
599 if ( nRead
== (size_t)wxInvalidOffset
)
601 wxPrintf(wxT("Failed to read the file."));
605 fwrite(buf
, nRead
, 1, stdout
);
611 wxPuts(wxT("----------"));
615 wxPrintf(wxT("ERROR: can't open test file.\n"));
618 wxPuts(wxEmptyString
);
621 static void TestTextFileRead()
623 wxPuts(wxT("*** wxTextFile read test ***"));
625 wxTextFile
file(wxT("testdata.fc"));
628 wxPrintf(wxT("Number of lines: %u\n"), file
.GetLineCount());
629 wxPrintf(wxT("Last line: '%s'\n"), file
.GetLastLine().c_str());
633 wxPuts(wxT("\nDumping the entire file:"));
634 for ( s
= file
.GetFirstLine(); !file
.Eof(); s
= file
.GetNextLine() )
636 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
638 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
640 wxPuts(wxT("\nAnd now backwards:"));
641 for ( s
= file
.GetLastLine();
642 file
.GetCurrentLine() != 0;
643 s
= file
.GetPrevLine() )
645 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
647 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
651 wxPrintf(wxT("ERROR: can't open '%s'\n"), file
.GetName());
654 wxPuts(wxEmptyString
);
657 static void TestFileCopy()
659 wxPuts(wxT("*** Testing wxCopyFile ***"));
661 static const wxChar
*filename1
= wxT("testdata.fc");
662 static const wxChar
*filename2
= wxT("test2");
663 if ( !wxCopyFile(filename1
, filename2
) )
665 wxPuts(wxT("ERROR: failed to copy file"));
669 wxFFile
f1(filename1
, wxT("rb")),
670 f2(filename2
, wxT("rb"));
672 if ( !f1
.IsOpened() || !f2
.IsOpened() )
674 wxPuts(wxT("ERROR: failed to open file(s)"));
679 if ( !f1
.ReadAll(&s1
) || !f2
.ReadAll(&s2
) )
681 wxPuts(wxT("ERROR: failed to read file(s)"));
685 if ( (s1
.length() != s2
.length()) ||
686 (memcmp(s1
.c_str(), s2
.c_str(), s1
.length()) != 0) )
688 wxPuts(wxT("ERROR: copy error!"));
692 wxPuts(wxT("File was copied ok."));
698 if ( !wxRemoveFile(filename2
) )
700 wxPuts(wxT("ERROR: failed to remove the file"));
703 wxPuts(wxEmptyString
);
706 static void TestTempFile()
708 wxPuts(wxT("*** wxTempFile test ***"));
711 if ( tmpFile
.Open(wxT("test2")) && tmpFile
.Write(wxT("the answer is 42")) )
713 if ( tmpFile
.Commit() )
714 wxPuts(wxT("File committed."));
716 wxPuts(wxT("ERROR: could't commit temp file."));
718 wxRemoveFile(wxT("test2"));
721 wxPuts(wxEmptyString
);
726 // ----------------------------------------------------------------------------
728 // ----------------------------------------------------------------------------
732 #include "wx/confbase.h"
733 #include "wx/fileconf.h"
735 static const struct FileConfTestData
737 const wxChar
*name
; // value name
738 const wxChar
*value
; // the value from the file
741 { wxT("value1"), wxT("one") },
742 { wxT("value2"), wxT("two") },
743 { wxT("novalue"), wxT("default") },
746 static void TestFileConfRead()
748 wxPuts(wxT("*** testing wxFileConfig loading/reading ***"));
750 wxFileConfig
fileconf(wxT("test"), wxEmptyString
,
751 wxT("testdata.fc"), wxEmptyString
,
752 wxCONFIG_USE_RELATIVE_PATH
);
754 // test simple reading
755 wxPuts(wxT("\nReading config file:"));
756 wxString
defValue(wxT("default")), value
;
757 for ( size_t n
= 0; n
< WXSIZEOF(fcTestData
); n
++ )
759 const FileConfTestData
& data
= fcTestData
[n
];
760 value
= fileconf
.Read(data
.name
, defValue
);
761 wxPrintf(wxT("\t%s = %s "), data
.name
, value
.c_str());
762 if ( value
== data
.value
)
768 wxPrintf(wxT("(ERROR: should be %s)\n"), data
.value
);
772 // test enumerating the entries
773 wxPuts(wxT("\nEnumerating all root entries:"));
776 bool cont
= fileconf
.GetFirstEntry(name
, dummy
);
779 wxPrintf(wxT("\t%s = %s\n"),
781 fileconf
.Read(name
.c_str(), wxT("ERROR")).c_str());
783 cont
= fileconf
.GetNextEntry(name
, dummy
);
786 static const wxChar
*testEntry
= wxT("TestEntry");
787 wxPrintf(wxT("\nTesting deletion of newly created \"Test\" entry: "));
788 fileconf
.Write(testEntry
, wxT("A value"));
789 fileconf
.DeleteEntry(testEntry
);
790 wxPrintf(fileconf
.HasEntry(testEntry
) ? wxT("ERROR\n") : wxT("ok\n"));
793 #endif // TEST_FILECONF
795 // ----------------------------------------------------------------------------
797 // ----------------------------------------------------------------------------
801 #include "wx/filename.h"
804 static void DumpFileName(const wxChar
*desc
, const wxFileName
& fn
)
808 wxString full
= fn
.GetFullPath();
810 wxString vol
, path
, name
, ext
;
811 wxFileName::SplitPath(full
, &vol
, &path
, &name
, &ext
);
813 wxPrintf(wxT("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
814 full
.c_str(), vol
.c_str(), path
.c_str(), name
.c_str(), ext
.c_str());
816 wxFileName::SplitPath(full
, &path
, &name
, &ext
);
817 wxPrintf(wxT("or\t\t-> path '%s', name '%s', ext '%s'\n"),
818 path
.c_str(), name
.c_str(), ext
.c_str());
820 wxPrintf(wxT("path is also:\t'%s'\n"), fn
.GetPath().c_str());
821 wxPrintf(wxT("with volume: \t'%s'\n"),
822 fn
.GetPath(wxPATH_GET_VOLUME
).c_str());
823 wxPrintf(wxT("with separator:\t'%s'\n"),
824 fn
.GetPath(wxPATH_GET_SEPARATOR
).c_str());
825 wxPrintf(wxT("with both: \t'%s'\n"),
826 fn
.GetPath(wxPATH_GET_SEPARATOR
| wxPATH_GET_VOLUME
).c_str());
828 wxPuts(wxT("The directories in the path are:"));
829 wxArrayString dirs
= fn
.GetDirs();
830 size_t count
= dirs
.GetCount();
831 for ( size_t n
= 0; n
< count
; n
++ )
833 wxPrintf(wxT("\t%u: %s\n"), n
, dirs
[n
].c_str());
838 static void TestFileNameTemp()
840 wxPuts(wxT("*** testing wxFileName temp file creation ***"));
842 static const wxChar
*tmpprefixes
[] =
850 wxT("/tmp/foo/bar"), // this one must be an error
854 for ( size_t n
= 0; n
< WXSIZEOF(tmpprefixes
); n
++ )
856 wxString path
= wxFileName::CreateTempFileName(tmpprefixes
[n
]);
859 // "error" is not in upper case because it may be ok
860 wxPrintf(wxT("Prefix '%s'\t-> error\n"), tmpprefixes
[n
]);
864 wxPrintf(wxT("Prefix '%s'\t-> temp file '%s'\n"),
865 tmpprefixes
[n
], path
.c_str());
867 if ( !wxRemoveFile(path
) )
869 wxLogWarning(wxT("Failed to remove temp file '%s'"),
876 static void TestFileNameDirManip()
878 // TODO: test AppendDir(), RemoveDir(), ...
881 static void TestFileNameComparison()
886 static void TestFileNameOperations()
891 static void TestFileNameCwd()
896 #endif // TEST_FILENAME
898 // ----------------------------------------------------------------------------
899 // wxFileName time functions
900 // ----------------------------------------------------------------------------
904 #include "wx/filename.h"
905 #include "wx/datetime.h"
907 static void TestFileGetTimes()
909 wxFileName
fn(wxT("testdata.fc"));
911 wxDateTime dtAccess
, dtMod
, dtCreate
;
912 if ( !fn
.GetTimes(&dtAccess
, &dtMod
, &dtCreate
) )
914 wxPrintf(wxT("ERROR: GetTimes() failed.\n"));
918 static const wxChar
*fmt
= wxT("%Y-%b-%d %H:%M:%S");
920 wxPrintf(wxT("File times for '%s':\n"), fn
.GetFullPath().c_str());
921 wxPrintf(wxT("Creation: \t%s\n"), dtCreate
.Format(fmt
).c_str());
922 wxPrintf(wxT("Last read: \t%s\n"), dtAccess
.Format(fmt
).c_str());
923 wxPrintf(wxT("Last write: \t%s\n"), dtMod
.Format(fmt
).c_str());
928 static void TestFileSetTimes()
930 wxFileName
fn(wxT("testdata.fc"));
934 wxPrintf(wxT("ERROR: Touch() failed.\n"));
939 #endif // TEST_FILETIME
941 // ----------------------------------------------------------------------------
943 // ----------------------------------------------------------------------------
948 #include "wx/utils.h" // for wxSetEnv
950 static wxLocale gs_localeDefault
;
951 // NOTE: don't init it here as it needs a wxAppTraits object
952 // and thus must be init-ed after creation of the wxInitializer
953 // class in the main()
955 // find the name of the language from its value
956 static const wxChar
*GetLangName(int lang
)
958 static const wxChar
*languageNames
[] =
968 wxT("ARABIC_ALGERIA"),
969 wxT("ARABIC_BAHRAIN"),
972 wxT("ARABIC_JORDAN"),
973 wxT("ARABIC_KUWAIT"),
974 wxT("ARABIC_LEBANON"),
976 wxT("ARABIC_MOROCCO"),
979 wxT("ARABIC_SAUDI_ARABIA"),
982 wxT("ARABIC_TUNISIA"),
989 wxT("AZERI_CYRILLIC"),
1004 wxT("CHINESE_SIMPLIFIED"),
1005 wxT("CHINESE_TRADITIONAL"),
1006 wxT("CHINESE_HONGKONG"),
1007 wxT("CHINESE_MACAU"),
1008 wxT("CHINESE_SINGAPORE"),
1009 wxT("CHINESE_TAIWAN"),
1015 wxT("DUTCH_BELGIAN"),
1019 wxT("ENGLISH_AUSTRALIA"),
1020 wxT("ENGLISH_BELIZE"),
1021 wxT("ENGLISH_BOTSWANA"),
1022 wxT("ENGLISH_CANADA"),
1023 wxT("ENGLISH_CARIBBEAN"),
1024 wxT("ENGLISH_DENMARK"),
1025 wxT("ENGLISH_EIRE"),
1026 wxT("ENGLISH_JAMAICA"),
1027 wxT("ENGLISH_NEW_ZEALAND"),
1028 wxT("ENGLISH_PHILIPPINES"),
1029 wxT("ENGLISH_SOUTH_AFRICA"),
1030 wxT("ENGLISH_TRINIDAD"),
1031 wxT("ENGLISH_ZIMBABWE"),
1039 wxT("FRENCH_BELGIAN"),
1040 wxT("FRENCH_CANADIAN"),
1041 wxT("FRENCH_LUXEMBOURG"),
1042 wxT("FRENCH_MONACO"),
1043 wxT("FRENCH_SWISS"),
1048 wxT("GERMAN_AUSTRIAN"),
1049 wxT("GERMAN_BELGIUM"),
1050 wxT("GERMAN_LIECHTENSTEIN"),
1051 wxT("GERMAN_LUXEMBOURG"),
1052 wxT("GERMAN_SWISS"),
1069 wxT("ITALIAN_SWISS"),
1074 wxT("KASHMIRI_INDIA"),
1092 wxT("MALAY_BRUNEI_DARUSSALAM"),
1093 wxT("MALAY_MALAYSIA"),
1102 wxT("NEPALI_INDIA"),
1103 wxT("NORWEGIAN_BOKMAL"),
1104 wxT("NORWEGIAN_NYNORSK"),
1111 wxT("PORTUGUESE_BRAZILIAN"),
1114 wxT("RHAETO_ROMANCE"),
1117 wxT("RUSSIAN_UKRAINE"),
1121 wxT("SCOTS_GAELIC"),
1123 wxT("SERBIAN_CYRILLIC"),
1124 wxT("SERBIAN_LATIN"),
1125 wxT("SERBO_CROATIAN"),
1136 wxT("SPANISH_ARGENTINA"),
1137 wxT("SPANISH_BOLIVIA"),
1138 wxT("SPANISH_CHILE"),
1139 wxT("SPANISH_COLOMBIA"),
1140 wxT("SPANISH_COSTA_RICA"),
1141 wxT("SPANISH_DOMINICAN_REPUBLIC"),
1142 wxT("SPANISH_ECUADOR"),
1143 wxT("SPANISH_EL_SALVADOR"),
1144 wxT("SPANISH_GUATEMALA"),
1145 wxT("SPANISH_HONDURAS"),
1146 wxT("SPANISH_MEXICAN"),
1147 wxT("SPANISH_MODERN"),
1148 wxT("SPANISH_NICARAGUA"),
1149 wxT("SPANISH_PANAMA"),
1150 wxT("SPANISH_PARAGUAY"),
1151 wxT("SPANISH_PERU"),
1152 wxT("SPANISH_PUERTO_RICO"),
1153 wxT("SPANISH_URUGUAY"),
1155 wxT("SPANISH_VENEZUELA"),
1159 wxT("SWEDISH_FINLAND"),
1177 wxT("URDU_PAKISTAN"),
1179 wxT("UZBEK_CYRILLIC"),
1192 if ( (size_t)lang
< WXSIZEOF(languageNames
) )
1193 return languageNames
[lang
];
1195 return wxT("INVALID");
1198 static void TestDefaultLang()
1200 wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
1202 gs_localeDefault
.Init(wxLANGUAGE_ENGLISH
);
1204 static const wxChar
*langStrings
[] =
1206 NULL
, // system default
1213 wxT("de_DE.iso88591"),
1215 wxT("?"), // invalid lang spec
1216 wxT("klingonese"), // I bet on some systems it does exist...
1219 wxPrintf(wxT("The default system encoding is %s (%d)\n"),
1220 wxLocale::GetSystemEncodingName().c_str(),
1221 wxLocale::GetSystemEncoding());
1223 for ( size_t n
= 0; n
< WXSIZEOF(langStrings
); n
++ )
1225 const wxChar
*langStr
= langStrings
[n
];
1228 // FIXME: this doesn't do anything at all under Windows, we need
1229 // to create a new wxLocale!
1230 wxSetEnv(wxT("LC_ALL"), langStr
);
1233 int lang
= gs_localeDefault
.GetSystemLanguage();
1234 wxPrintf(wxT("Locale for '%s' is %s.\n"),
1235 langStr
? langStr
: wxT("system default"), GetLangName(lang
));
1239 #endif // TEST_LOCALE
1241 // ----------------------------------------------------------------------------
1243 // ----------------------------------------------------------------------------
1247 #include "wx/mimetype.h"
1249 static void TestMimeEnum()
1251 wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1253 wxArrayString mimetypes
;
1255 size_t count
= wxTheMimeTypesManager
->EnumAllFileTypes(mimetypes
);
1257 wxPrintf(wxT("*** All %u known filetypes: ***\n"), count
);
1262 for ( size_t n
= 0; n
< count
; n
++ )
1264 wxFileType
*filetype
=
1265 wxTheMimeTypesManager
->GetFileTypeFromMimeType(mimetypes
[n
]);
1268 wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
1269 mimetypes
[n
].c_str());
1273 filetype
->GetDescription(&desc
);
1274 filetype
->GetExtensions(exts
);
1276 filetype
->GetIcon(NULL
);
1279 for ( size_t e
= 0; e
< exts
.GetCount(); e
++ )
1282 extsAll
<< wxT(", ");
1286 wxPrintf(wxT("\t%s: %s (%s)\n"),
1287 mimetypes
[n
].c_str(), desc
.c_str(), extsAll
.c_str());
1290 wxPuts(wxEmptyString
);
1293 static void TestMimeFilename()
1295 wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
1297 static const wxChar
*filenames
[] =
1300 wxT("document.pdf"),
1302 wxT("picture.jpeg"),
1305 for ( size_t n
= 0; n
< WXSIZEOF(filenames
); n
++ )
1307 const wxString fname
= filenames
[n
];
1308 wxString ext
= fname
.AfterLast(wxT('.'));
1309 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
1312 wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext
.c_str());
1317 if ( !ft
->GetDescription(&desc
) )
1318 desc
= wxT("<no description>");
1321 if ( !ft
->GetOpenCommand(&cmd
,
1322 wxFileType::MessageParameters(fname
, wxEmptyString
)) )
1323 cmd
= wxT("<no command available>");
1325 cmd
= wxString(wxT('"')) + cmd
+ wxT('"');
1327 wxPrintf(wxT("To open %s (%s) do %s.\n"),
1328 fname
.c_str(), desc
.c_str(), cmd
.c_str());
1334 wxPuts(wxEmptyString
);
1337 // these tests were broken by wxMimeTypesManager changes, temporarily disabling
1340 static void TestMimeOverride()
1342 wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
1344 static const wxChar
*mailcap
= wxT("/tmp/mailcap");
1345 static const wxChar
*mimetypes
= wxT("/tmp/mime.types");
1347 if ( wxFile::Exists(mailcap
) )
1348 wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
1350 wxTheMimeTypesManager
->ReadMailcap(mailcap
) ? wxT("ok") : wxT("ERROR"));
1352 wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1355 if ( wxFile::Exists(mimetypes
) )
1356 wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
1358 wxTheMimeTypesManager
->ReadMimeTypes(mimetypes
) ? wxT("ok") : wxT("ERROR"));
1360 wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1363 wxPuts(wxEmptyString
);
1366 static void TestMimeAssociate()
1368 wxPuts(wxT("*** Testing creation of filetype association ***\n"));
1370 wxFileTypeInfo
ftInfo(
1371 wxT("application/x-xyz"),
1372 wxT("xyzview '%s'"), // open cmd
1373 wxT(""), // print cmd
1374 wxT("XYZ File"), // description
1375 wxT(".xyz"), // extensions
1376 wxNullPtr
// end of extensions
1378 ftInfo
.SetShortDesc(wxT("XYZFile")); // used under Win32 only
1380 wxFileType
*ft
= wxTheMimeTypesManager
->Associate(ftInfo
);
1383 wxPuts(wxT("ERROR: failed to create association!"));
1387 // TODO: read it back
1391 wxPuts(wxEmptyString
);
1398 // ----------------------------------------------------------------------------
1399 // module dependencies feature
1400 // ----------------------------------------------------------------------------
1404 #include "wx/module.h"
1406 class wxTestModule
: public wxModule
1409 virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1410 virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1413 class wxTestModuleA
: public wxTestModule
1418 DECLARE_DYNAMIC_CLASS(wxTestModuleA
)
1421 class wxTestModuleB
: public wxTestModule
1426 DECLARE_DYNAMIC_CLASS(wxTestModuleB
)
1429 class wxTestModuleC
: public wxTestModule
1434 DECLARE_DYNAMIC_CLASS(wxTestModuleC
)
1437 class wxTestModuleD
: public wxTestModule
1442 DECLARE_DYNAMIC_CLASS(wxTestModuleD
)
1445 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC
, wxModule
)
1446 wxTestModuleC::wxTestModuleC()
1448 AddDependency(CLASSINFO(wxTestModuleD
));
1451 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA
, wxModule
)
1452 wxTestModuleA::wxTestModuleA()
1454 AddDependency(CLASSINFO(wxTestModuleB
));
1455 AddDependency(CLASSINFO(wxTestModuleD
));
1458 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD
, wxModule
)
1459 wxTestModuleD::wxTestModuleD()
1463 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB
, wxModule
)
1464 wxTestModuleB::wxTestModuleB()
1466 AddDependency(CLASSINFO(wxTestModuleD
));
1467 AddDependency(CLASSINFO(wxTestModuleC
));
1470 #endif // TEST_MODULE
1472 // ----------------------------------------------------------------------------
1473 // misc information functions
1474 // ----------------------------------------------------------------------------
1476 #ifdef TEST_INFO_FUNCTIONS
1478 #include "wx/utils.h"
1480 #if TEST_INTERACTIVE
1481 static void TestDiskInfo()
1483 wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
1487 wxChar pathname
[128];
1488 wxPrintf(wxT("\nEnter a directory name: "));
1489 if ( !wxFgets(pathname
, WXSIZEOF(pathname
), stdin
) )
1492 // kill the last '\n'
1493 pathname
[wxStrlen(pathname
) - 1] = 0;
1495 wxLongLong total
, free
;
1496 if ( !wxGetDiskSpace(pathname
, &total
, &free
) )
1498 wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
1502 wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
1503 (total
/ 1024).ToString().c_str(),
1504 (free
/ 1024).ToString().c_str(),
1509 #endif // TEST_INTERACTIVE
1511 static void TestOsInfo()
1513 wxPuts(wxT("*** Testing OS info functions ***\n"));
1516 wxGetOsVersion(&major
, &minor
);
1517 wxPrintf(wxT("Running under: %s, version %d.%d\n"),
1518 wxGetOsDescription().c_str(), major
, minor
);
1520 wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1522 wxPrintf(wxT("Host name is %s (%s).\n"),
1523 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1525 wxPuts(wxEmptyString
);
1528 static void TestPlatformInfo()
1530 wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
1532 // get this platform
1533 wxPlatformInfo plat
;
1535 wxPrintf(wxT("Operating system family name is: %s\n"), plat
.GetOperatingSystemFamilyName().c_str());
1536 wxPrintf(wxT("Operating system name is: %s\n"), plat
.GetOperatingSystemIdName().c_str());
1537 wxPrintf(wxT("Port ID name is: %s\n"), plat
.GetPortIdName().c_str());
1538 wxPrintf(wxT("Port ID short name is: %s\n"), plat
.GetPortIdShortName().c_str());
1539 wxPrintf(wxT("Architecture is: %s\n"), plat
.GetArchName().c_str());
1540 wxPrintf(wxT("Endianness is: %s\n"), plat
.GetEndiannessName().c_str());
1542 wxPuts(wxEmptyString
);
1545 static void TestUserInfo()
1547 wxPuts(wxT("*** Testing user info functions ***\n"));
1549 wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
1550 wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
1551 wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1552 wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1554 wxPuts(wxEmptyString
);
1557 #endif // TEST_INFO_FUNCTIONS
1559 // ----------------------------------------------------------------------------
1561 // ----------------------------------------------------------------------------
1563 #ifdef TEST_PATHLIST
1566 #define CMD_IN_PATH wxT("ls")
1568 #define CMD_IN_PATH wxT("command.com")
1571 static void TestPathList()
1573 wxPuts(wxT("*** Testing wxPathList ***\n"));
1575 wxPathList pathlist
;
1576 pathlist
.AddEnvList(wxT("PATH"));
1577 wxString path
= pathlist
.FindValidPath(CMD_IN_PATH
);
1580 wxPrintf(wxT("ERROR: command not found in the path.\n"));
1584 wxPrintf(wxT("Command found in the path as '%s'.\n"), path
.c_str());
1588 #endif // TEST_PATHLIST
1590 // ----------------------------------------------------------------------------
1591 // regular expressions
1592 // ----------------------------------------------------------------------------
1594 #if defined TEST_REGEX && TEST_INTERACTIVE
1596 #include "wx/regex.h"
1598 static void TestRegExInteractive()
1600 wxPuts(wxT("*** Testing RE interactively ***"));
1604 wxChar pattern
[128];
1605 wxPrintf(wxT("\nEnter a pattern: "));
1606 if ( !wxFgets(pattern
, WXSIZEOF(pattern
), stdin
) )
1609 // kill the last '\n'
1610 pattern
[wxStrlen(pattern
) - 1] = 0;
1613 if ( !re
.Compile(pattern
) )
1621 wxPrintf(wxT("Enter text to match: "));
1622 if ( !wxFgets(text
, WXSIZEOF(text
), stdin
) )
1625 // kill the last '\n'
1626 text
[wxStrlen(text
) - 1] = 0;
1628 if ( !re
.Matches(text
) )
1630 wxPrintf(wxT("No match.\n"));
1634 wxPrintf(wxT("Pattern matches at '%s'\n"), re
.GetMatch(text
).c_str());
1637 for ( size_t n
= 1; ; n
++ )
1639 if ( !re
.GetMatch(&start
, &len
, n
) )
1644 wxPrintf(wxT("Subexpr %u matched '%s'\n"),
1645 n
, wxString(text
+ start
, len
).c_str());
1652 #endif // TEST_REGEX
1654 // ----------------------------------------------------------------------------
1656 // ----------------------------------------------------------------------------
1659 NB: this stuff was taken from the glibc test suite and modified to build
1660 in wxWidgets: if I read the copyright below properly, this shouldn't
1666 #ifdef wxTEST_PRINTF
1667 // use our functions from wxchar.cpp
1671 // NB: do _not_ use WX_ATTRIBUTE_PRINTF here, we have some invalid formats
1672 // in the tests below
1673 int wxPrintf( const wxChar
*format
, ... );
1674 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... );
1677 #include "wx/longlong.h"
1681 static void rfg1 (void);
1682 static void rfg2 (void);
1686 fmtchk (const wxChar
*fmt
)
1688 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1689 (void) wxPrintf(fmt
, 0x12);
1690 (void) wxPrintf(wxT("'\n"));
1694 fmtst1chk (const wxChar
*fmt
)
1696 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1697 (void) wxPrintf(fmt
, 4, 0x12);
1698 (void) wxPrintf(wxT("'\n"));
1702 fmtst2chk (const wxChar
*fmt
)
1704 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1705 (void) wxPrintf(fmt
, 4, 4, 0x12);
1706 (void) wxPrintf(wxT("'\n"));
1709 /* This page is covered by the following copyright: */
1711 /* (C) Copyright C E Chew
1713 * Feel free to copy, use and distribute this software provided:
1715 * 1. you do not pretend that you wrote it
1716 * 2. you leave this copyright notice intact.
1720 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1727 /* Formatted Output Test
1729 * This exercises the output formatting code.
1732 wxChar
*PointerNull
= NULL
;
1739 wxChar
*prefix
= buf
;
1742 wxPuts(wxT("\nFormatted output test"));
1743 wxPrintf(wxT("prefix 6d 6o 6x 6X 6u\n"));
1744 wxStrcpy(prefix
, wxT("%"));
1745 for (i
= 0; i
< 2; i
++) {
1746 for (j
= 0; j
< 2; j
++) {
1747 for (k
= 0; k
< 2; k
++) {
1748 for (l
= 0; l
< 2; l
++) {
1749 wxStrcpy(prefix
, wxT("%"));
1750 if (i
== 0) wxStrcat(prefix
, wxT("-"));
1751 if (j
== 0) wxStrcat(prefix
, wxT("+"));
1752 if (k
== 0) wxStrcat(prefix
, wxT("#"));
1753 if (l
== 0) wxStrcat(prefix
, wxT("0"));
1754 wxPrintf(wxT("%5s |"), prefix
);
1755 wxStrcpy(tp
, prefix
);
1756 wxStrcat(tp
, wxT("6d |"));
1758 wxStrcpy(tp
, prefix
);
1759 wxStrcat(tp
, wxT("6o |"));
1761 wxStrcpy(tp
, prefix
);
1762 wxStrcat(tp
, wxT("6x |"));
1764 wxStrcpy(tp
, prefix
);
1765 wxStrcat(tp
, wxT("6X |"));
1767 wxStrcpy(tp
, prefix
);
1768 wxStrcat(tp
, wxT("6u |"));
1770 wxPrintf(wxT("\n"));
1775 wxPrintf(wxT("%10s\n"), PointerNull
);
1776 wxPrintf(wxT("%-10s\n"), PointerNull
);
1779 static void TestPrintf()
1781 static wxChar shortstr
[] = wxT("Hi, Z.");
1782 static wxChar longstr
[] = wxT("Good morning, Doctor Chandra. This is Hal. \
1783 I am ready for my first lesson today.");
1785 wxString test_format
;
1787 fmtchk(wxT("%.4x"));
1788 fmtchk(wxT("%04x"));
1789 fmtchk(wxT("%4.4x"));
1790 fmtchk(wxT("%04.4x"));
1791 fmtchk(wxT("%4.3x"));
1792 fmtchk(wxT("%04.3x"));
1794 fmtst1chk(wxT("%.*x"));
1795 fmtst1chk(wxT("%0*x"));
1796 fmtst2chk(wxT("%*.*x"));
1797 fmtst2chk(wxT("%0*.*x"));
1799 wxString bad_format
= wxT("bad format:\t\"%b\"\n");
1800 wxPrintf(bad_format
.c_str());
1801 wxPrintf(wxT("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL
);
1803 wxPrintf(wxT("decimal negative:\t\"%d\"\n"), -2345);
1804 wxPrintf(wxT("octal negative:\t\"%o\"\n"), -2345);
1805 wxPrintf(wxT("hex negative:\t\"%x\"\n"), -2345);
1806 wxPrintf(wxT("long decimal number:\t\"%ld\"\n"), -123456L);
1807 wxPrintf(wxT("long octal negative:\t\"%lo\"\n"), -2345L);
1808 wxPrintf(wxT("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
1809 wxPrintf(wxT("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
1810 test_format
= wxT("left-adjusted ZLDN:\t\"%-010ld\"\n");
1811 wxPrintf(test_format
.c_str(), -123456);
1812 wxPrintf(wxT("space-padded LDN:\t\"%10ld\"\n"), -123456L);
1813 wxPrintf(wxT("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
1815 test_format
= wxT("zero-padded string:\t\"%010s\"\n");
1816 wxPrintf(test_format
.c_str(), shortstr
);
1817 test_format
= wxT("left-adjusted Z string:\t\"%-010s\"\n");
1818 wxPrintf(test_format
.c_str(), shortstr
);
1819 wxPrintf(wxT("space-padded string:\t\"%10s\"\n"), shortstr
);
1820 wxPrintf(wxT("left-adjusted S string:\t\"%-10s\"\n"), shortstr
);
1821 wxPrintf(wxT("null string:\t\"%s\"\n"), PointerNull
);
1822 wxPrintf(wxT("limited string:\t\"%.22s\"\n"), longstr
);
1824 wxPrintf(wxT("e-style >= 1:\t\"%e\"\n"), 12.34);
1825 wxPrintf(wxT("e-style >= .1:\t\"%e\"\n"), 0.1234);
1826 wxPrintf(wxT("e-style < .1:\t\"%e\"\n"), 0.001234);
1827 wxPrintf(wxT("e-style big:\t\"%.60e\"\n"), 1e20
);
1828 wxPrintf(wxT("e-style == .1:\t\"%e\"\n"), 0.1);
1829 wxPrintf(wxT("f-style >= 1:\t\"%f\"\n"), 12.34);
1830 wxPrintf(wxT("f-style >= .1:\t\"%f\"\n"), 0.1234);
1831 wxPrintf(wxT("f-style < .1:\t\"%f\"\n"), 0.001234);
1832 wxPrintf(wxT("g-style >= 1:\t\"%g\"\n"), 12.34);
1833 wxPrintf(wxT("g-style >= .1:\t\"%g\"\n"), 0.1234);
1834 wxPrintf(wxT("g-style < .1:\t\"%g\"\n"), 0.001234);
1835 wxPrintf(wxT("g-style big:\t\"%.60g\"\n"), 1e20
);
1837 wxPrintf (wxT(" %6.5f\n"), .099999999860301614);
1838 wxPrintf (wxT(" %6.5f\n"), .1);
1839 wxPrintf (wxT("x%5.4fx\n"), .5);
1841 wxPrintf (wxT("%#03x\n"), 1);
1843 //wxPrintf (wxT("something really insane: %.10000f\n"), 1.0);
1849 while (niter
-- != 0)
1850 wxPrintf (wxT("%.17e\n"), d
/ 2);
1855 // Open Watcom cause compiler error here
1856 // Error! E173: col(24) floating-point constant too small to represent
1857 wxPrintf (wxT("%15.5e\n"), 4.9406564584124654e-324);
1860 #define FORMAT wxT("|%12.4f|%12.4e|%12.4g|\n")
1861 wxPrintf (FORMAT
, 0.0, 0.0, 0.0);
1862 wxPrintf (FORMAT
, 1.0, 1.0, 1.0);
1863 wxPrintf (FORMAT
, -1.0, -1.0, -1.0);
1864 wxPrintf (FORMAT
, 100.0, 100.0, 100.0);
1865 wxPrintf (FORMAT
, 1000.0, 1000.0, 1000.0);
1866 wxPrintf (FORMAT
, 10000.0, 10000.0, 10000.0);
1867 wxPrintf (FORMAT
, 12345.0, 12345.0, 12345.0);
1868 wxPrintf (FORMAT
, 100000.0, 100000.0, 100000.0);
1869 wxPrintf (FORMAT
, 123456.0, 123456.0, 123456.0);
1874 int rc
= wxSnprintf (buf
, WXSIZEOF(buf
), wxT("%30s"), wxT("foo"));
1876 wxPrintf(wxT("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1877 rc
, WXSIZEOF(buf
), buf
);
1880 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1881 wxSnprintf(buf2
, WXSIZEOFbuf2
), "%.999999u", 10));
1887 wxPrintf (wxT("%e should be 1.234568e+06\n"), 1234567.8);
1888 wxPrintf (wxT("%f should be 1234567.800000\n"), 1234567.8);
1889 wxPrintf (wxT("%g should be 1.23457e+06\n"), 1234567.8);
1890 wxPrintf (wxT("%g should be 123.456\n"), 123.456);
1891 wxPrintf (wxT("%g should be 1e+06\n"), 1000000.0);
1892 wxPrintf (wxT("%g should be 10\n"), 10.0);
1893 wxPrintf (wxT("%g should be 0.02\n"), 0.02);
1897 wxPrintf(wxT("%.17f\n"),(1.0/x
/10.0+1.0)*x
-x
);
1903 wxSprintf(buf
,wxT("%*s%*s%*s"),-1,wxT("one"),-20,wxT("two"),-30,wxT("three"));
1905 result
|= wxStrcmp (buf
,
1906 wxT("onetwo three "));
1908 wxPuts (result
!= 0 ? wxT("Test failed!") : wxT("Test ok."));
1915 wxSprintf(buf
, "%07" wxLongLongFmtSpec
"o", wxLL(040000000000));
1917 // for some reason below line fails under Borland
1918 wxPrintf (wxT("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf
);
1921 if (wxStrcmp (buf
, wxT("40000000000")) != 0)
1924 wxPuts (wxT("\tFAILED"));
1926 wxUnusedVar(result
);
1927 wxPuts (wxEmptyString
);
1929 #endif // wxLongLong_t
1931 wxPrintf (wxT("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX
+ 2, UCHAR_MAX
+ 2);
1932 wxPrintf (wxT("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX
+ 2, USHRT_MAX
+ 2);
1934 wxPuts (wxT("--- Should be no further output. ---"));
1943 memset (bytes
, '\xff', sizeof bytes
);
1944 wxSprintf (buf
, wxT("foo%hhn\n"), &bytes
[3]);
1945 if (bytes
[0] != '\xff' || bytes
[1] != '\xff' || bytes
[2] != '\xff'
1946 || bytes
[4] != '\xff' || bytes
[5] != '\xff' || bytes
[6] != '\xff')
1948 wxPuts (wxT("%hhn overwrite more bytes"));
1953 wxPuts (wxT("%hhn wrote incorrect value"));
1965 wxSprintf (buf
, wxT("%5.s"), wxT("xyz"));
1966 if (wxStrcmp (buf
, wxT(" ")) != 0)
1967 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" "));
1968 wxSprintf (buf
, wxT("%5.f"), 33.3);
1969 if (wxStrcmp (buf
, wxT(" 33")) != 0)
1970 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 33"));
1971 wxSprintf (buf
, wxT("%8.e"), 33.3e7
);
1972 if (wxStrcmp (buf
, wxT(" 3e+08")) != 0)
1973 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3e+08"));
1974 wxSprintf (buf
, wxT("%8.E"), 33.3e7
);
1975 if (wxStrcmp (buf
, wxT(" 3E+08")) != 0)
1976 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3E+08"));
1977 wxSprintf (buf
, wxT("%.g"), 33.3);
1978 if (wxStrcmp (buf
, wxT("3e+01")) != 0)
1979 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3e+01"));
1980 wxSprintf (buf
, wxT("%.G"), 33.3);
1981 if (wxStrcmp (buf
, wxT("3E+01")) != 0)
1982 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3E+01"));
1990 wxString test_format
;
1993 wxSprintf (buf
, wxT("%.*g"), prec
, 3.3);
1994 if (wxStrcmp (buf
, wxT("3")) != 0)
1995 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
1997 wxSprintf (buf
, wxT("%.*G"), prec
, 3.3);
1998 if (wxStrcmp (buf
, wxT("3")) != 0)
1999 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
2001 wxSprintf (buf
, wxT("%7.*G"), prec
, 3.33);
2002 if (wxStrcmp (buf
, wxT(" 3")) != 0)
2003 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3"));
2005 test_format
= wxT("%04.*o");
2006 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2007 if (wxStrcmp (buf
, wxT(" 041")) != 0)
2008 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 041"));
2010 test_format
= wxT("%09.*u");
2011 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2012 if (wxStrcmp (buf
, wxT(" 0000033")) != 0)
2013 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 0000033"));
2015 test_format
= wxT("%04.*x");
2016 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2017 if (wxStrcmp (buf
, wxT(" 021")) != 0)
2018 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
2020 test_format
= wxT("%04.*X");
2021 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
2022 if (wxStrcmp (buf
, wxT(" 021")) != 0)
2023 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
2026 #endif // TEST_PRINTF
2028 // ----------------------------------------------------------------------------
2029 // registry and related stuff
2030 // ----------------------------------------------------------------------------
2032 // this is for MSW only
2035 #undef TEST_REGISTRY
2040 #include "wx/confbase.h"
2041 #include "wx/msw/regconf.h"
2044 static void TestRegConfWrite()
2046 wxConfig
*config
= new wxConfig(wxT("myapp"));
2047 config
->SetPath(wxT("/group1"));
2048 config
->Write(wxT("entry1"), wxT("foo"));
2049 config
->SetPath(wxT("/group2"));
2050 config
->Write(wxT("entry1"), wxT("bar"));
2054 static void TestRegConfRead()
2056 wxRegConfig
*config
= new wxRegConfig(wxT("myapp"));
2060 config
->SetPath(wxT("/"));
2061 wxPuts(wxT("Enumerating / subgroups:"));
2062 bool bCont
= config
->GetFirstGroup(str
, dummy
);
2066 bCont
= config
->GetNextGroup(str
, dummy
);
2070 #endif // TEST_REGCONF
2072 #ifdef TEST_REGISTRY
2074 #include "wx/msw/registry.h"
2076 // I chose this one because I liked its name, but it probably only exists under
2078 static const wxChar
*TESTKEY
=
2079 wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
2081 static void TestRegistryRead()
2083 wxPuts(wxT("*** testing registry reading ***"));
2085 wxRegKey
key(TESTKEY
);
2086 wxPrintf(wxT("The test key name is '%s'.\n"), key
.GetName().c_str());
2089 wxPuts(wxT("ERROR: test key can't be opened, aborting test."));
2094 size_t nSubKeys
, nValues
;
2095 if ( key
.GetKeyInfo(&nSubKeys
, NULL
, &nValues
, NULL
) )
2097 wxPrintf(wxT("It has %u subkeys and %u values.\n"), nSubKeys
, nValues
);
2100 wxPrintf(wxT("Enumerating values:\n"));
2104 bool cont
= key
.GetFirstValue(value
, dummy
);
2107 wxPrintf(wxT("Value '%s': type "), value
.c_str());
2108 switch ( key
.GetValueType(value
) )
2110 case wxRegKey::Type_None
: wxPrintf(wxT("ERROR (none)")); break;
2111 case wxRegKey::Type_String
: wxPrintf(wxT("SZ")); break;
2112 case wxRegKey::Type_Expand_String
: wxPrintf(wxT("EXPAND_SZ")); break;
2113 case wxRegKey::Type_Binary
: wxPrintf(wxT("BINARY")); break;
2114 case wxRegKey::Type_Dword
: wxPrintf(wxT("DWORD")); break;
2115 case wxRegKey::Type_Multi_String
: wxPrintf(wxT("MULTI_SZ")); break;
2116 default: wxPrintf(wxT("other (unknown)")); break;
2119 wxPrintf(wxT(", value = "));
2120 if ( key
.IsNumericValue(value
) )
2123 key
.QueryValue(value
, &val
);
2124 wxPrintf(wxT("%ld"), val
);
2129 key
.QueryValue(value
, val
);
2130 wxPrintf(wxT("'%s'"), val
.c_str());
2132 key
.QueryRawValue(value
, val
);
2133 wxPrintf(wxT(" (raw value '%s')"), val
.c_str());
2138 cont
= key
.GetNextValue(value
, dummy
);
2142 static void TestRegistryAssociation()
2145 The second call to deleteself genertaes an error message, with a
2146 messagebox saying .flo is crucial to system operation, while the .ddf
2147 call also fails, but with no error message
2152 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2154 key
= wxT("ddxf_auto_file") ;
2155 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2157 key
= wxT("ddxf_auto_file") ;
2158 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2160 key
= wxT("program,0") ;
2161 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2163 key
= wxT("program \"%1\"") ;
2165 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2167 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2169 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2171 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2175 #endif // TEST_REGISTRY
2177 // ----------------------------------------------------------------------------
2179 // ----------------------------------------------------------------------------
2181 #ifdef TEST_SCOPEGUARD
2183 #include "wx/scopeguard.h"
2185 static void function0() { puts("function0()"); }
2186 static void function1(int n
) { printf("function1(%d)\n", n
); }
2187 static void function2(double x
, char c
) { printf("function2(%g, %c)\n", x
, c
); }
2191 void method0() { printf("method0()\n"); }
2192 void method1(int n
) { printf("method1(%d)\n", n
); }
2193 void method2(double x
, char c
) { printf("method2(%g, %c)\n", x
, c
); }
2196 static void TestScopeGuard()
2198 wxON_BLOCK_EXIT0(function0
);
2199 wxON_BLOCK_EXIT1(function1
, 17);
2200 wxON_BLOCK_EXIT2(function2
, 3.14, 'p');
2203 wxON_BLOCK_EXIT_OBJ0(obj
, Object::method0
);
2204 wxON_BLOCK_EXIT_OBJ1(obj
, Object::method1
, 7);
2205 wxON_BLOCK_EXIT_OBJ2(obj
, Object::method2
, 2.71, 'e');
2207 wxScopeGuard dismissed
= wxMakeGuard(function0
);
2208 dismissed
.Dismiss();
2213 // ----------------------------------------------------------------------------
2215 // ----------------------------------------------------------------------------
2219 #include "wx/socket.h"
2220 #include "wx/protocol/protocol.h"
2221 #include "wx/protocol/http.h"
2223 static void TestSocketServer()
2225 wxPuts(wxT("*** Testing wxSocketServer ***\n"));
2227 static const int PORT
= 3000;
2232 wxSocketServer
*server
= new wxSocketServer(addr
);
2233 if ( !server
->Ok() )
2235 wxPuts(wxT("ERROR: failed to bind"));
2243 wxPrintf(wxT("Server: waiting for connection on port %d...\n"), PORT
);
2245 wxSocketBase
*socket
= server
->Accept();
2248 wxPuts(wxT("ERROR: wxSocketServer::Accept() failed."));
2252 wxPuts(wxT("Server: got a client."));
2254 server
->SetTimeout(60); // 1 min
2257 while ( !close
&& socket
->IsConnected() )
2260 wxChar ch
= wxT('\0');
2263 if ( socket
->Read(&ch
, sizeof(ch
)).Error() )
2265 // don't log error if the client just close the connection
2266 if ( socket
->IsConnected() )
2268 wxPuts(wxT("ERROR: in wxSocket::Read."));
2288 wxPrintf(wxT("Server: got '%s'.\n"), s
.c_str());
2289 if ( s
== wxT("close") )
2291 wxPuts(wxT("Closing connection"));
2295 else if ( s
== wxT("quit") )
2300 wxPuts(wxT("Shutting down the server"));
2302 else // not a special command
2304 socket
->Write(s
.MakeUpper().c_str(), s
.length());
2305 socket
->Write("\r\n", 2);
2306 wxPrintf(wxT("Server: wrote '%s'.\n"), s
.c_str());
2312 wxPuts(wxT("Server: lost a client unexpectedly."));
2318 // same as "delete server" but is consistent with GUI programs
2322 static void TestSocketClient()
2324 wxPuts(wxT("*** Testing wxSocketClient ***\n"));
2326 static const wxChar
*hostname
= wxT("www.wxwidgets.org");
2329 addr
.Hostname(hostname
);
2332 wxPrintf(wxT("--- Attempting to connect to %s:80...\n"), hostname
);
2334 wxSocketClient client
;
2335 if ( !client
.Connect(addr
) )
2337 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname
);
2341 wxPrintf(wxT("--- Connected to %s:%u...\n"),
2342 addr
.Hostname().c_str(), addr
.Service());
2346 // could use simply "GET" here I suppose
2348 wxString::Format(wxT("GET http://%s/\r\n"), hostname
);
2349 client
.Write(cmdGet
, cmdGet
.length());
2350 wxPrintf(wxT("--- Sent command '%s' to the server\n"),
2351 MakePrintable(cmdGet
).c_str());
2352 client
.Read(buf
, WXSIZEOF(buf
));
2353 wxPrintf(wxT("--- Server replied:\n%s"), buf
);
2357 #endif // TEST_SOCKETS
2359 // ----------------------------------------------------------------------------
2361 // ----------------------------------------------------------------------------
2365 #include "wx/protocol/ftp.h"
2366 #include "wx/protocol/log.h"
2368 #define FTP_ANONYMOUS
2372 #ifdef FTP_ANONYMOUS
2373 static const wxChar
*directory
= wxT("/pub");
2374 static const wxChar
*filename
= wxT("welcome.msg");
2376 static const wxChar
*directory
= wxT("/etc");
2377 static const wxChar
*filename
= wxT("issue");
2380 static bool TestFtpConnect()
2382 wxPuts(wxT("*** Testing FTP connect ***"));
2384 #ifdef FTP_ANONYMOUS
2385 static const wxChar
*hostname
= wxT("ftp.wxwidgets.org");
2387 wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname
);
2388 #else // !FTP_ANONYMOUS
2389 static const wxChar
*hostname
= "localhost";
2392 wxFgets(user
, WXSIZEOF(user
), stdin
);
2393 user
[wxStrlen(user
) - 1] = '\0'; // chop off '\n'
2396 wxChar password
[256];
2397 wxPrintf(wxT("Password for %s: "), password
);
2398 wxFgets(password
, WXSIZEOF(password
), stdin
);
2399 password
[wxStrlen(password
) - 1] = '\0'; // chop off '\n'
2400 ftp
->SetPassword(password
);
2402 wxPrintf(wxT("--- Attempting to connect to %s:21 as %s...\n"), hostname
, user
);
2403 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2405 if ( !ftp
->Connect(hostname
) )
2407 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname
);
2413 wxPrintf(wxT("--- Connected to %s, current directory is '%s'\n"),
2414 hostname
, ftp
->Pwd().c_str());
2421 static void TestFtpList()
2423 wxPuts(wxT("*** Testing wxFTP file listing ***\n"));
2426 if ( !ftp
->ChDir(directory
) )
2428 wxPrintf(wxT("ERROR: failed to cd to %s\n"), directory
);
2431 wxPrintf(wxT("Current directory is '%s'\n"), ftp
->Pwd().c_str());
2433 // test NLIST and LIST
2434 wxArrayString files
;
2435 if ( !ftp
->GetFilesList(files
) )
2437 wxPuts(wxT("ERROR: failed to get NLIST of files"));
2441 wxPrintf(wxT("Brief list of files under '%s':\n"), ftp
->Pwd().c_str());
2442 size_t count
= files
.GetCount();
2443 for ( size_t n
= 0; n
< count
; n
++ )
2445 wxPrintf(wxT("\t%s\n"), files
[n
].c_str());
2447 wxPuts(wxT("End of the file list"));
2450 if ( !ftp
->GetDirList(files
) )
2452 wxPuts(wxT("ERROR: failed to get LIST of files"));
2456 wxPrintf(wxT("Detailed list of files under '%s':\n"), ftp
->Pwd().c_str());
2457 size_t count
= files
.GetCount();
2458 for ( size_t n
= 0; n
< count
; n
++ )
2460 wxPrintf(wxT("\t%s\n"), files
[n
].c_str());
2462 wxPuts(wxT("End of the file list"));
2465 if ( !ftp
->ChDir(wxT("..")) )
2467 wxPuts(wxT("ERROR: failed to cd to .."));
2470 wxPrintf(wxT("Current directory is '%s'\n"), ftp
->Pwd().c_str());
2473 static void TestFtpDownload()
2475 wxPuts(wxT("*** Testing wxFTP download ***\n"));
2478 wxInputStream
*in
= ftp
->GetInputStream(filename
);
2481 wxPrintf(wxT("ERROR: couldn't get input stream for %s\n"), filename
);
2485 size_t size
= in
->GetSize();
2486 wxPrintf(wxT("Reading file %s (%u bytes)..."), filename
, size
);
2489 wxChar
*data
= new wxChar
[size
];
2490 if ( !in
->Read(data
, size
) )
2492 wxPuts(wxT("ERROR: read error"));
2496 wxPrintf(wxT("\nContents of %s:\n%s\n"), filename
, data
);
2504 static void TestFtpFileSize()
2506 wxPuts(wxT("*** Testing FTP SIZE command ***"));
2508 if ( !ftp
->ChDir(directory
) )
2510 wxPrintf(wxT("ERROR: failed to cd to %s\n"), directory
);
2513 wxPrintf(wxT("Current directory is '%s'\n"), ftp
->Pwd().c_str());
2515 if ( ftp
->FileExists(filename
) )
2517 int size
= ftp
->GetFileSize(filename
);
2519 wxPrintf(wxT("ERROR: couldn't get size of '%s'\n"), filename
);
2521 wxPrintf(wxT("Size of '%s' is %d bytes.\n"), filename
, size
);
2525 wxPrintf(wxT("ERROR: '%s' doesn't exist\n"), filename
);
2529 static void TestFtpMisc()
2531 wxPuts(wxT("*** Testing miscellaneous wxFTP functions ***"));
2533 if ( ftp
->SendCommand(wxT("STAT")) != '2' )
2535 wxPuts(wxT("ERROR: STAT failed"));
2539 wxPrintf(wxT("STAT returned:\n\n%s\n"), ftp
->GetLastResult().c_str());
2542 if ( ftp
->SendCommand(wxT("HELP SITE")) != '2' )
2544 wxPuts(wxT("ERROR: HELP SITE failed"));
2548 wxPrintf(wxT("The list of site-specific commands:\n\n%s\n"),
2549 ftp
->GetLastResult().c_str());
2553 #if TEST_INTERACTIVE
2555 static void TestFtpInteractive()
2557 wxPuts(wxT("\n*** Interactive wxFTP test ***"));
2563 wxPrintf(wxT("Enter FTP command: "));
2564 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2567 // kill the last '\n'
2568 buf
[wxStrlen(buf
) - 1] = 0;
2570 // special handling of LIST and NLST as they require data connection
2571 wxString
start(buf
, 4);
2573 if ( start
== wxT("LIST") || start
== wxT("NLST") )
2576 if ( wxStrlen(buf
) > 4 )
2579 wxArrayString files
;
2580 if ( !ftp
->GetList(files
, wildcard
, start
== wxT("LIST")) )
2582 wxPrintf(wxT("ERROR: failed to get %s of files\n"), start
.c_str());
2586 wxPrintf(wxT("--- %s of '%s' under '%s':\n"),
2587 start
.c_str(), wildcard
.c_str(), ftp
->Pwd().c_str());
2588 size_t count
= files
.GetCount();
2589 for ( size_t n
= 0; n
< count
; n
++ )
2591 wxPrintf(wxT("\t%s\n"), files
[n
].c_str());
2593 wxPuts(wxT("--- End of the file list"));
2598 wxChar ch
= ftp
->SendCommand(buf
);
2599 wxPrintf(wxT("Command %s"), ch
? wxT("succeeded") : wxT("failed"));
2602 wxPrintf(wxT(" (return code %c)"), ch
);
2605 wxPrintf(wxT(", server reply:\n%s\n\n"), ftp
->GetLastResult().c_str());
2609 wxPuts(wxT("\n*** done ***"));
2612 #endif // TEST_INTERACTIVE
2614 static void TestFtpUpload()
2616 wxPuts(wxT("*** Testing wxFTP uploading ***\n"));
2619 static const wxChar
*file1
= wxT("test1");
2620 static const wxChar
*file2
= wxT("test2");
2621 wxOutputStream
*out
= ftp
->GetOutputStream(file1
);
2624 wxPrintf(wxT("--- Uploading to %s ---\n"), file1
);
2625 out
->Write("First hello", 11);
2629 // send a command to check the remote file
2630 if ( ftp
->SendCommand(wxString(wxT("STAT ")) + file1
) != '2' )
2632 wxPrintf(wxT("ERROR: STAT %s failed\n"), file1
);
2636 wxPrintf(wxT("STAT %s returned:\n\n%s\n"),
2637 file1
, ftp
->GetLastResult().c_str());
2640 out
= ftp
->GetOutputStream(file2
);
2643 wxPrintf(wxT("--- Uploading to %s ---\n"), file1
);
2644 out
->Write("Second hello", 12);
2651 // ----------------------------------------------------------------------------
2653 // ----------------------------------------------------------------------------
2655 #ifdef TEST_STACKWALKER
2657 #if wxUSE_STACKWALKER
2659 #include "wx/stackwalk.h"
2661 class StackDump
: public wxStackWalker
2664 StackDump(const char *argv0
)
2665 : wxStackWalker(argv0
)
2669 virtual void Walk(size_t skip
= 1, size_t maxdepth
= wxSTACKWALKER_MAX_DEPTH
)
2671 wxPuts(wxT("Stack dump:"));
2673 wxStackWalker::Walk(skip
, maxdepth
);
2677 virtual void OnStackFrame(const wxStackFrame
& frame
)
2679 printf("[%2d] ", (int) frame
.GetLevel());
2681 wxString name
= frame
.GetName();
2682 if ( !name
.empty() )
2684 printf("%-20.40s", (const char*)name
.mb_str());
2688 printf("0x%08lx", (unsigned long)frame
.GetAddress());
2691 if ( frame
.HasSourceLocation() )
2694 (const char*)frame
.GetFileName().mb_str(),
2695 (int)frame
.GetLine());
2701 for ( size_t n
= 0; frame
.GetParam(n
, &type
, &name
, &val
); n
++ )
2703 printf("\t%s %s = %s\n", (const char*)type
.mb_str(),
2704 (const char*)name
.mb_str(),
2705 (const char*)val
.mb_str());
2710 static void TestStackWalk(const char *argv0
)
2712 wxPuts(wxT("*** Testing wxStackWalker ***\n"));
2714 StackDump
dump(argv0
);
2718 #endif // wxUSE_STACKWALKER
2720 #endif // TEST_STACKWALKER
2722 // ----------------------------------------------------------------------------
2724 // ----------------------------------------------------------------------------
2726 #ifdef TEST_STDPATHS
2728 #include "wx/stdpaths.h"
2729 #include "wx/wxchar.h" // wxPrintf
2731 static void TestStandardPaths()
2733 wxPuts(wxT("*** Testing wxStandardPaths ***\n"));
2735 wxTheApp
->SetAppName(wxT("console"));
2737 wxStandardPathsBase
& stdp
= wxStandardPaths::Get();
2738 wxPrintf(wxT("Config dir (sys):\t%s\n"), stdp
.GetConfigDir().c_str());
2739 wxPrintf(wxT("Config dir (user):\t%s\n"), stdp
.GetUserConfigDir().c_str());
2740 wxPrintf(wxT("Data dir (sys):\t\t%s\n"), stdp
.GetDataDir().c_str());
2741 wxPrintf(wxT("Data dir (sys local):\t%s\n"), stdp
.GetLocalDataDir().c_str());
2742 wxPrintf(wxT("Data dir (user):\t%s\n"), stdp
.GetUserDataDir().c_str());
2743 wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp
.GetUserLocalDataDir().c_str());
2744 wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp
.GetDocumentsDir().c_str());
2745 wxPrintf(wxT("Executable path:\t%s\n"), stdp
.GetExecutablePath().c_str());
2746 wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp
.GetPluginsDir().c_str());
2747 wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp
.GetResourcesDir().c_str());
2748 wxPrintf(wxT("Localized res. dir:\t%s\n"),
2749 stdp
.GetLocalizedResourcesDir(wxT("fr")).c_str());
2750 wxPrintf(wxT("Message catalogs dir:\t%s\n"),
2751 stdp
.GetLocalizedResourcesDir
2754 wxStandardPaths::ResourceCat_Messages
2758 #endif // TEST_STDPATHS
2760 // ----------------------------------------------------------------------------
2762 // ----------------------------------------------------------------------------
2766 #include "wx/wfstream.h"
2767 #include "wx/mstream.h"
2769 static void TestFileStream()
2771 wxPuts(wxT("*** Testing wxFileInputStream ***"));
2773 static const wxString filename
= wxT("testdata.fs");
2775 wxFileOutputStream
fsOut(filename
);
2776 fsOut
.Write("foo", 3);
2780 wxFileInputStream
fsIn(filename
);
2781 wxPrintf(wxT("File stream size: %u\n"), fsIn
.GetSize());
2783 while ( (c
=fsIn
.GetC()) != wxEOF
)
2789 if ( !wxRemoveFile(filename
) )
2791 wxPrintf(wxT("ERROR: failed to remove the file '%s'.\n"), filename
.c_str());
2794 wxPuts(wxT("\n*** wxFileInputStream test done ***"));
2797 static void TestMemoryStream()
2799 wxPuts(wxT("*** Testing wxMemoryOutputStream ***"));
2801 wxMemoryOutputStream memOutStream
;
2802 wxPrintf(wxT("Initially out stream offset: %lu\n"),
2803 (unsigned long)memOutStream
.TellO());
2805 for ( const wxChar
*p
= wxT("Hello, stream!"); *p
; p
++ )
2807 memOutStream
.PutC(*p
);
2810 wxPrintf(wxT("Final out stream offset: %lu\n"),
2811 (unsigned long)memOutStream
.TellO());
2813 wxPuts(wxT("*** Testing wxMemoryInputStream ***"));
2816 size_t len
= memOutStream
.CopyTo(buf
, WXSIZEOF(buf
));
2818 wxMemoryInputStream
memInpStream(buf
, len
);
2819 wxPrintf(wxT("Memory stream size: %u\n"), memInpStream
.GetSize());
2821 while ( (c
=memInpStream
.GetC()) != wxEOF
)
2826 wxPuts(wxT("\n*** wxMemoryInputStream test done ***"));
2829 #endif // TEST_STREAMS
2831 // ----------------------------------------------------------------------------
2833 // ----------------------------------------------------------------------------
2837 #include "wx/stopwatch.h"
2838 #include "wx/utils.h"
2840 static void TestStopWatch()
2842 wxPuts(wxT("*** Testing wxStopWatch ***\n"));
2846 wxPrintf(wxT("Initially paused, after 2 seconds time is..."));
2849 wxPrintf(wxT("\t%ldms\n"), sw
.Time());
2851 wxPrintf(wxT("Resuming stopwatch and sleeping 3 seconds..."));
2855 wxPrintf(wxT("\telapsed time: %ldms\n"), sw
.Time());
2858 wxPrintf(wxT("Pausing agan and sleeping 2 more seconds..."));
2861 wxPrintf(wxT("\telapsed time: %ldms\n"), sw
.Time());
2864 wxPrintf(wxT("Finally resuming and sleeping 2 more seconds..."));
2867 wxPrintf(wxT("\telapsed time: %ldms\n"), sw
.Time());
2870 wxPuts(wxT("\nChecking for 'backwards clock' bug..."));
2871 for ( size_t n
= 0; n
< 70; n
++ )
2875 for ( size_t m
= 0; m
< 100000; m
++ )
2877 if ( sw
.Time() < 0 || sw2
.Time() < 0 )
2879 wxPuts(wxT("\ntime is negative - ERROR!"));
2887 wxPuts(wxT(", ok."));
2890 #include "wx/timer.h"
2891 #include "wx/evtloop.h"
2895 wxPuts(wxT("*** Testing wxTimer ***\n"));
2897 class MyTimer
: public wxTimer
2900 MyTimer() : wxTimer() { m_num
= 0; }
2902 virtual void Notify()
2904 wxPrintf(wxT("%d"), m_num
++);
2909 wxPrintf(wxT("... exiting the event loop"));
2912 wxEventLoop::GetActive()->Exit(0);
2913 wxPuts(wxT(", ok."));
2926 timer1
.Start(100, true /* one shot */);
2928 timer1
.Start(100, true /* one shot */);
2936 #endif // TEST_TIMER
2938 // ----------------------------------------------------------------------------
2940 // ----------------------------------------------------------------------------
2942 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
2948 #include "wx/volume.h"
2950 static const wxChar
*volumeKinds
[] =
2956 wxT("network volume"),
2957 wxT("other volume"),
2960 static void TestFSVolume()
2962 wxPuts(wxT("*** Testing wxFSVolume class ***"));
2964 wxArrayString volumes
= wxFSVolume::GetVolumes();
2965 size_t count
= volumes
.GetCount();
2969 wxPuts(wxT("ERROR: no mounted volumes?"));
2973 wxPrintf(wxT("%u mounted volumes found:\n"), count
);
2975 for ( size_t n
= 0; n
< count
; n
++ )
2977 wxFSVolume
vol(volumes
[n
]);
2980 wxPuts(wxT("ERROR: couldn't create volume"));
2984 wxPrintf(wxT("%u: %s (%s), %s, %s, %s\n"),
2986 vol
.GetDisplayName().c_str(),
2987 vol
.GetName().c_str(),
2988 volumeKinds
[vol
.GetKind()],
2989 vol
.IsWritable() ? wxT("rw") : wxT("ro"),
2990 vol
.GetFlags() & wxFS_VOL_REMOVABLE
? wxT("removable")
2995 #endif // TEST_VOLUME
2997 // ----------------------------------------------------------------------------
2998 // wide char and Unicode support
2999 // ----------------------------------------------------------------------------
3003 #include "wx/strconv.h"
3004 #include "wx/fontenc.h"
3005 #include "wx/encconv.h"
3006 #include "wx/buffer.h"
3008 static const unsigned char utf8koi8r
[] =
3010 208, 157, 208, 181, 209, 129, 208, 186, 208, 176, 208, 183, 208, 176,
3011 208, 189, 208, 189, 208, 190, 32, 208, 191, 208, 190, 209, 128, 208,
3012 176, 208, 180, 208, 190, 208, 178, 208, 176, 208, 187, 32, 208, 188,
3013 208, 181, 208, 189, 209, 143, 32, 209, 129, 208, 178, 208, 190, 208,
3014 181, 208, 185, 32, 208, 186, 209, 128, 209, 131, 209, 130, 208, 181,
3015 208, 185, 209, 136, 208, 181, 208, 185, 32, 208, 189, 208, 190, 208,
3016 178, 208, 190, 209, 129, 209, 130, 209, 140, 209, 142, 0
3019 static const unsigned char utf8iso8859_1
[] =
3021 0x53, 0x79, 0x73, 0x74, 0xc3, 0xa8, 0x6d, 0x65, 0x73, 0x20, 0x49, 0x6e,
3022 0x74, 0xc3, 0xa9, 0x67, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x65,
3023 0x6e, 0x20, 0x4d, 0xc3, 0xa9, 0x63, 0x61, 0x6e, 0x69, 0x71, 0x75, 0x65,
3024 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65,
3025 0x74, 0x20, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x71, 0x75, 0x65, 0
3028 static const unsigned char utf8Invalid
[] =
3030 0x3c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3e, 0x32, 0x30, 0x30,
3031 0x32, 0xe5, 0xb9, 0xb4, 0x30, 0x39, 0xe6, 0x9c, 0x88, 0x32, 0x35, 0xe6,
3032 0x97, 0xa5, 0x20, 0x30, 0x37, 0xe6, 0x99, 0x82, 0x33, 0x39, 0xe5, 0x88,
3033 0x86, 0x35, 0x37, 0xe7, 0xa7, 0x92, 0x3c, 0x2f, 0x64, 0x69, 0x73, 0x70,
3037 static const struct Utf8Data
3039 const unsigned char *text
;
3041 const wxChar
*charset
;
3042 wxFontEncoding encoding
;
3045 { utf8Invalid
, WXSIZEOF(utf8Invalid
), wxT("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3046 { utf8koi8r
, WXSIZEOF(utf8koi8r
), wxT("koi8-r"), wxFONTENCODING_KOI8
},
3047 { utf8iso8859_1
, WXSIZEOF(utf8iso8859_1
), wxT("iso8859-1"), wxFONTENCODING_ISO8859_1
},
3050 static void TestUtf8()
3052 wxPuts(wxT("*** Testing UTF8 support ***\n"));
3057 for ( size_t n
= 0; n
< WXSIZEOF(utf8data
); n
++ )
3059 const Utf8Data
& u8d
= utf8data
[n
];
3060 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)u8d
.text
,
3061 WXSIZEOF(wbuf
)) == (size_t)-1 )
3063 wxPuts(wxT("ERROR: UTF-8 decoding failed."));
3067 wxCSConv
conv(u8d
.charset
);
3068 if ( conv
.WC2MB(buf
, wbuf
, WXSIZEOF(buf
)) == (size_t)-1 )
3070 wxPrintf(wxT("ERROR: conversion to %s failed.\n"), u8d
.charset
);
3074 wxPrintf(wxT("String in %s: %s\n"), u8d
.charset
, buf
);
3078 wxString
s(wxConvUTF8
.cMB2WC((const char *)u8d
.text
));
3080 s
= wxT("<< conversion failed >>");
3081 wxPrintf(wxT("String in current cset: %s\n"), s
.c_str());
3085 wxPuts(wxEmptyString
);
3088 static void TestEncodingConverter()
3090 wxPuts(wxT("*** Testing wxEncodingConverter ***\n"));
3092 // using wxEncodingConverter should give the same result as above
3095 if ( wxConvUTF8
.MB2WC(wbuf
, (const char *)utf8koi8r
,
3096 WXSIZEOF(utf8koi8r
)) == (size_t)-1 )
3098 wxPuts(wxT("ERROR: UTF-8 decoding failed."));
3102 wxEncodingConverter ec
;
3103 ec
.Init(wxFONTENCODING_UNICODE
, wxFONTENCODING_KOI8
);
3104 ec
.Convert(wbuf
, buf
);
3105 wxPrintf(wxT("The same KOI8-R string using wxEC: %s\n"), buf
);
3108 wxPuts(wxEmptyString
);
3111 #endif // TEST_WCHAR
3114 // ----------------------------------------------------------------------------
3116 // ----------------------------------------------------------------------------
3118 #ifdef TEST_DATETIME
3120 #include "wx/math.h"
3121 #include "wx/datetime.h"
3123 #if TEST_INTERACTIVE
3125 static void TestDateTimeInteractive()
3127 wxPuts(wxT("\n*** interactive wxDateTime tests ***"));
3133 wxPrintf(wxT("Enter a date: "));
3134 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
3137 // kill the last '\n'
3138 buf
[wxStrlen(buf
) - 1] = 0;
3141 const wxChar
*p
= dt
.ParseDate(buf
);
3144 wxPrintf(wxT("ERROR: failed to parse the date '%s'.\n"), buf
);
3150 wxPrintf(wxT("WARNING: parsed only first %u characters.\n"), p
- buf
);
3153 wxPrintf(wxT("%s: day %u, week of month %u/%u, week of year %u\n"),
3154 dt
.Format(wxT("%b %d, %Y")).c_str(),
3156 dt
.GetWeekOfMonth(wxDateTime::Monday_First
),
3157 dt
.GetWeekOfMonth(wxDateTime::Sunday_First
),
3158 dt
.GetWeekOfYear(wxDateTime::Monday_First
));
3161 wxPuts(wxT("\n*** done ***"));
3164 #endif // TEST_INTERACTIVE
3165 #endif // TEST_DATETIME
3167 // ----------------------------------------------------------------------------
3169 // ----------------------------------------------------------------------------
3171 #ifdef TEST_SNGLINST
3172 #include "wx/snglinst.h"
3173 #endif // TEST_SNGLINST
3175 int main(int argc
, char **argv
)
3178 wxChar
**wxArgv
= new wxChar
*[argc
+ 1];
3183 for (n
= 0; n
< argc
; n
++ )
3185 wxMB2WXbuf warg
= wxConvertMB2WX(argv
[n
]);
3186 wxArgv
[n
] = wxStrdup(warg
);
3191 #else // !wxUSE_UNICODE
3193 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
3195 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE
, "program");
3197 wxInitializer initializer
;
3200 fprintf(stderr
, "Failed to initialize the wxWidgets library, aborting.");
3205 #ifdef TEST_SNGLINST
3206 wxSingleInstanceChecker checker
;
3207 if ( checker
.Create(wxT(".wxconsole.lock")) )
3209 if ( checker
.IsAnotherRunning() )
3211 wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
3216 // wait some time to give time to launch another instance
3217 wxPrintf(wxT("Press \"Enter\" to continue..."));
3220 else // failed to create
3222 wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
3224 #endif // TEST_SNGLINST
3227 TestCmdLineConvert();
3229 #if wxUSE_CMDLINE_PARSER
3230 static const wxCmdLineEntryDesc cmdLineDesc
[] =
3232 { wxCMD_LINE_SWITCH
, "h", "help", "show this help message",
3233 wxCMD_LINE_VAL_NONE
, wxCMD_LINE_OPTION_HELP
},
3234 { wxCMD_LINE_SWITCH
, "v", "verbose", "be verbose" },
3235 { wxCMD_LINE_SWITCH
, "q", "quiet", "be quiet" },
3237 { wxCMD_LINE_OPTION
, "o", "output", "output file" },
3238 { wxCMD_LINE_OPTION
, "i", "input", "input dir" },
3239 { wxCMD_LINE_OPTION
, "s", "size", "output block size",
3240 wxCMD_LINE_VAL_NUMBER
},
3241 { wxCMD_LINE_OPTION
, "d", "date", "output file date",
3242 wxCMD_LINE_VAL_DATE
},
3243 { wxCMD_LINE_OPTION
, "f", "double", "output double",
3244 wxCMD_LINE_VAL_DOUBLE
},
3246 { wxCMD_LINE_PARAM
, NULL
, NULL
, "input file",
3247 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_MULTIPLE
},
3252 wxCmdLineParser
parser(cmdLineDesc
, argc
, wxArgv
);
3254 parser
.AddOption(wxT("project_name"), wxT(""), wxT("full path to project file"),
3255 wxCMD_LINE_VAL_STRING
,
3256 wxCMD_LINE_OPTION_MANDATORY
| wxCMD_LINE_NEEDS_SEPARATOR
);
3258 switch ( parser
.Parse() )
3261 wxLogMessage(wxT("Help was given, terminating."));
3265 ShowCmdLine(parser
);
3269 wxLogMessage(wxT("Syntax error detected, aborting."));
3272 #endif // wxUSE_CMDLINE_PARSER
3274 #endif // TEST_CMDLINE
3286 TestDllListLoaded();
3287 #endif // TEST_DYNLIB
3291 #endif // TEST_ENVIRON
3293 #ifdef TEST_FILECONF
3295 #endif // TEST_FILECONF
3299 #endif // TEST_LOCALE
3302 wxPuts(wxT("*** Testing wxLog ***"));
3305 for ( size_t n
= 0; n
< 8000; n
++ )
3307 s
<< (wxChar
)(wxT('A') + (n
% 26));
3310 wxLogWarning(wxT("The length of the string is %lu"),
3311 (unsigned long)s
.length());
3314 msg
.Printf(wxT("A very very long message: '%s', the end!\n"), s
.c_str());
3316 // this one shouldn't be truncated
3319 // but this one will because log functions use fixed size buffer
3320 // (note that it doesn't need '\n' at the end neither - will be added
3322 wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s
.c_str());
3332 #ifdef TEST_FILENAME
3335 TestFileNameDirManip();
3336 TestFileNameComparison();
3337 TestFileNameOperations();
3338 #endif // TEST_FILENAME
3340 #ifdef TEST_FILETIME
3345 #endif // TEST_FILETIME
3348 wxLog::AddTraceMask(FTP_TRACE_MASK
);
3350 // wxFTP cannot be a static variable as its ctor needs to access
3351 // wxWidgets internals after it has been initialized
3353 ftp
->SetLog(new wxProtocolLog(FTP_TRACE_MASK
));
3355 if ( TestFtpConnect() )
3365 #if TEST_INTERACTIVE
3366 //TestFtpInteractive();
3369 //else: connecting to the FTP server failed
3375 //wxLog::AddTraceMask(wxT("mime"));
3379 TestMimeAssociate();
3384 #ifdef TEST_INFO_FUNCTIONS
3389 #if TEST_INTERACTIVE
3392 #endif // TEST_INFO_FUNCTIONS
3394 #ifdef TEST_PATHLIST
3396 #endif // TEST_PATHLIST
3400 #endif // TEST_PRINTF
3407 #endif // TEST_REGCONF
3409 #if defined TEST_REGEX && TEST_INTERACTIVE
3410 TestRegExInteractive();
3411 #endif // defined TEST_REGEX && TEST_INTERACTIVE
3413 #ifdef TEST_REGISTRY
3415 TestRegistryAssociation();
3416 #endif // TEST_REGISTRY
3421 #endif // TEST_SOCKETS
3428 #endif // TEST_STREAMS
3433 #endif // TEST_TIMER
3435 #ifdef TEST_DATETIME
3436 #if TEST_INTERACTIVE
3437 TestDateTimeInteractive();
3439 #endif // TEST_DATETIME
3441 #ifdef TEST_SCOPEGUARD
3445 #ifdef TEST_STACKWALKER
3446 #if wxUSE_STACKWALKER
3447 TestStackWalk(argv
[0]);
3449 #endif // TEST_STACKWALKER
3451 #ifdef TEST_STDPATHS
3452 TestStandardPaths();
3456 wxPuts(wxT("Sleeping for 3 seconds... z-z-z-z-z..."));
3458 #endif // TEST_USLEEP
3462 #endif // TEST_VOLUME
3466 TestEncodingConverter();
3467 #endif // TEST_WCHAR
3471 for ( int n
= 0; n
< argc
; n
++ )
3476 #endif // wxUSE_UNICODE