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.
108 #define TEST_DATETIME
113 #define TEST_FILECONF
114 #define TEST_FILENAME
115 #define TEST_FILETIME
116 #define TEST_INFO_FUNCTIONS
121 #define TEST_PATHLIST
125 #define TEST_REGISTRY
126 #define TEST_SCOPEGUARD
127 #else // #if TEST_ALL
128 #define TEST_DATETIME
130 #define TEST_STDPATHS
131 #define TEST_STACKWALKER
133 #define TEST_SNGLINST
136 // some tests are interactive, define this to run them
137 #ifdef TEST_INTERACTIVE
138 #undef TEST_INTERACTIVE
140 #define TEST_INTERACTIVE 1
142 #define TEST_INTERACTIVE 1
145 // ============================================================================
147 // ============================================================================
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
158 static const wxChar
*ROOTDIR
= wxT("/");
159 static const wxChar
*TESTDIR
= wxT("/usr/local/share");
160 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
161 static const wxChar
*ROOTDIR
= wxT("c:\\");
162 static const wxChar
*TESTDIR
= wxT("d:\\");
164 #error "don't know where the root directory is"
167 static void TestDirEnumHelper(wxDir
& dir
,
168 int flags
= wxDIR_DEFAULT
,
169 const wxString
& filespec
= wxEmptyString
)
173 if ( !dir
.IsOpened() )
176 bool cont
= dir
.GetFirst(&filename
, filespec
, flags
);
179 wxPrintf(wxT("\t%s\n"), filename
.c_str());
181 cont
= dir
.GetNext(&filename
);
184 wxPuts(wxEmptyString
);
189 static void TestDirEnum()
191 wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
193 wxString cwd
= wxGetCwd();
194 if ( !wxDir::Exists(cwd
) )
196 wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd
.c_str());
201 if ( !dir
.IsOpened() )
203 wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd
.c_str());
207 wxPuts(wxT("Enumerating everything in current directory:"));
208 TestDirEnumHelper(dir
);
210 wxPuts(wxT("Enumerating really everything in current directory:"));
211 TestDirEnumHelper(dir
, wxDIR_DEFAULT
| wxDIR_DOTDOT
);
213 wxPuts(wxT("Enumerating object files in current directory:"));
214 TestDirEnumHelper(dir
, wxDIR_DEFAULT
, wxT("*.o*"));
216 wxPuts(wxT("Enumerating directories in current directory:"));
217 TestDirEnumHelper(dir
, wxDIR_DIRS
);
219 wxPuts(wxT("Enumerating files in current directory:"));
220 TestDirEnumHelper(dir
, wxDIR_FILES
);
222 wxPuts(wxT("Enumerating files including hidden in current directory:"));
223 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
227 wxPuts(wxT("Enumerating everything in root directory:"));
228 TestDirEnumHelper(dir
, wxDIR_DEFAULT
);
230 wxPuts(wxT("Enumerating directories in root directory:"));
231 TestDirEnumHelper(dir
, wxDIR_DIRS
);
233 wxPuts(wxT("Enumerating files in root directory:"));
234 TestDirEnumHelper(dir
, wxDIR_FILES
);
236 wxPuts(wxT("Enumerating files including hidden in root directory:"));
237 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
239 wxPuts(wxT("Enumerating files in non existing directory:"));
240 wxDir
dirNo(wxT("nosuchdir"));
241 TestDirEnumHelper(dirNo
);
246 class DirPrintTraverser
: public wxDirTraverser
249 virtual wxDirTraverseResult
OnFile(const wxString
& WXUNUSED(filename
))
251 return wxDIR_CONTINUE
;
254 virtual wxDirTraverseResult
OnDir(const wxString
& dirname
)
256 wxString path
, name
, ext
;
257 wxFileName::SplitPath(dirname
, &path
, &name
, &ext
);
260 name
<< wxT('.') << ext
;
263 for ( const wxChar
*p
= path
.c_str(); *p
; p
++ )
265 if ( wxIsPathSeparator(*p
) )
269 wxPrintf(wxT("%s%s\n"), indent
.c_str(), name
.c_str());
271 return wxDIR_CONTINUE
;
275 static void TestDirTraverse()
277 wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
281 size_t n
= wxDir::GetAllFiles(TESTDIR
, &files
);
282 wxPrintf(wxT("There are %u files under '%s'\n"), n
, TESTDIR
);
285 wxPrintf(wxT("First one is '%s'\n"), files
[0u].c_str());
286 wxPrintf(wxT(" last one is '%s'\n"), files
[n
- 1].c_str());
289 // enum again with custom traverser
290 wxPuts(wxT("Now enumerating directories:"));
292 DirPrintTraverser traverser
;
293 dir
.Traverse(traverser
, wxEmptyString
, wxDIR_DIRS
| wxDIR_HIDDEN
);
298 static void TestDirExists()
300 wxPuts(wxT("*** Testing wxDir::Exists() ***"));
302 static const wxChar
*dirnames
[] =
305 #if defined(__WXMSW__)
308 wxT("\\\\share\\file"),
312 wxT("c:\\autoexec.bat"),
313 #elif defined(__UNIX__)
322 for ( size_t n
= 0; n
< WXSIZEOF(dirnames
); n
++ )
324 wxPrintf(wxT("%-40s: %s\n"),
326 wxDir::Exists(dirnames
[n
]) ? wxT("exists")
327 : wxT("doesn't exist"));
335 // ----------------------------------------------------------------------------
337 // ----------------------------------------------------------------------------
341 #include "wx/dynlib.h"
343 static void TestDllLoad()
345 #if defined(__WXMSW__)
346 static const wxChar
*LIB_NAME
= wxT("kernel32.dll");
347 static const wxChar
*FUNC_NAME
= wxT("lstrlenA");
348 #elif defined(__UNIX__)
349 // weird: using just libc.so does *not* work!
350 static const wxChar
*LIB_NAME
= wxT("/lib/libc.so.6");
351 static const wxChar
*FUNC_NAME
= wxT("strlen");
353 #error "don't know how to test wxDllLoader on this platform"
356 wxPuts(wxT("*** testing basic wxDynamicLibrary functions ***\n"));
358 wxDynamicLibrary
lib(LIB_NAME
);
359 if ( !lib
.IsLoaded() )
361 wxPrintf(wxT("ERROR: failed to load '%s'.\n"), LIB_NAME
);
365 typedef int (wxSTDCALL
*wxStrlenType
)(const char *);
366 wxStrlenType pfnStrlen
= (wxStrlenType
)lib
.GetSymbol(FUNC_NAME
);
369 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
370 FUNC_NAME
, LIB_NAME
);
374 wxPrintf(wxT("Calling %s dynamically loaded from %s "),
375 FUNC_NAME
, LIB_NAME
);
377 if ( pfnStrlen("foo") != 3 )
379 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
383 wxPuts(wxT("... ok"));
388 static const wxChar
*FUNC_NAME_AW
= wxT("lstrlen");
390 typedef int (wxSTDCALL
*wxStrlenTypeAorW
)(const wxChar
*);
392 pfnStrlenAorW
= (wxStrlenTypeAorW
)lib
.GetSymbolAorW(FUNC_NAME_AW
);
393 if ( !pfnStrlenAorW
)
395 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
396 FUNC_NAME_AW
, LIB_NAME
);
400 if ( pfnStrlenAorW(wxT("foobar")) != 6 )
402 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
409 #if defined(__WXMSW__) || defined(__UNIX__)
411 static void TestDllListLoaded()
413 wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
415 puts("\nLoaded modules:");
416 wxDynamicLibraryDetailsArray dlls
= wxDynamicLibrary::ListLoaded();
417 const size_t count
= dlls
.GetCount();
418 for ( size_t n
= 0; n
< count
; ++n
)
420 const wxDynamicLibraryDetails
& details
= dlls
[n
];
421 printf("%-45s", (const char *)details
.GetPath().mb_str());
423 void *addr
wxDUMMY_INITIALIZE(NULL
);
424 size_t len
wxDUMMY_INITIALIZE(0);
425 if ( details
.GetAddress(&addr
, &len
) )
427 printf(" %08lx:%08lx",
428 (unsigned long)addr
, (unsigned long)((char *)addr
+ len
));
431 printf(" %s\n", (const char *)details
.GetVersion().mb_str());
437 #endif // TEST_DYNLIB
439 // ----------------------------------------------------------------------------
441 // ----------------------------------------------------------------------------
445 #include "wx/utils.h"
447 static wxString
MyGetEnv(const wxString
& var
)
450 if ( !wxGetEnv(var
, &val
) )
451 val
= wxT("<empty>");
453 val
= wxString(wxT('\'')) + val
+ wxT('\'');
458 static void TestEnvironment()
460 const wxChar
*var
= wxT("wxTestVar");
462 wxPuts(wxT("*** testing environment access functions ***"));
464 wxPrintf(wxT("Initially getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
465 wxSetEnv(var
, wxT("value for wxTestVar"));
466 wxPrintf(wxT("After wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
467 wxSetEnv(var
, wxT("another value"));
468 wxPrintf(wxT("After 2nd wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
470 wxPrintf(wxT("After wxUnsetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
471 wxPrintf(wxT("PATH = %s\n"), MyGetEnv(wxT("PATH")).c_str());
474 #endif // TEST_ENVIRON
476 // ----------------------------------------------------------------------------
478 // ----------------------------------------------------------------------------
483 #include "wx/ffile.h"
484 #include "wx/textfile.h"
486 static void TestFileRead()
488 wxPuts(wxT("*** wxFile read test ***"));
490 wxFile
file(wxT("testdata.fc"));
491 if ( file
.IsOpened() )
493 wxPrintf(wxT("File length: %lu\n"), file
.Length());
495 wxPuts(wxT("File dump:\n----------"));
497 static const size_t len
= 1024;
501 size_t nRead
= file
.Read(buf
, len
);
502 if ( nRead
== (size_t)wxInvalidOffset
)
504 wxPrintf(wxT("Failed to read the file."));
508 fwrite(buf
, nRead
, 1, stdout
);
514 wxPuts(wxT("----------"));
518 wxPrintf(wxT("ERROR: can't open test file.\n"));
521 wxPuts(wxEmptyString
);
524 static void TestTextFileRead()
526 wxPuts(wxT("*** wxTextFile read test ***"));
528 wxTextFile
file(wxT("testdata.fc"));
531 wxPrintf(wxT("Number of lines: %u\n"), file
.GetLineCount());
532 wxPrintf(wxT("Last line: '%s'\n"), file
.GetLastLine().c_str());
536 wxPuts(wxT("\nDumping the entire file:"));
537 for ( s
= file
.GetFirstLine(); !file
.Eof(); s
= file
.GetNextLine() )
539 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
541 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
543 wxPuts(wxT("\nAnd now backwards:"));
544 for ( s
= file
.GetLastLine();
545 file
.GetCurrentLine() != 0;
546 s
= file
.GetPrevLine() )
548 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
550 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
554 wxPrintf(wxT("ERROR: can't open '%s'\n"), file
.GetName());
557 wxPuts(wxEmptyString
);
560 static void TestFileCopy()
562 wxPuts(wxT("*** Testing wxCopyFile ***"));
564 static const wxChar
*filename1
= wxT("testdata.fc");
565 static const wxChar
*filename2
= wxT("test2");
566 if ( !wxCopyFile(filename1
, filename2
) )
568 wxPuts(wxT("ERROR: failed to copy file"));
572 wxFFile
f1(filename1
, wxT("rb")),
573 f2(filename2
, wxT("rb"));
575 if ( !f1
.IsOpened() || !f2
.IsOpened() )
577 wxPuts(wxT("ERROR: failed to open file(s)"));
582 if ( !f1
.ReadAll(&s1
) || !f2
.ReadAll(&s2
) )
584 wxPuts(wxT("ERROR: failed to read file(s)"));
588 if ( (s1
.length() != s2
.length()) ||
589 (memcmp(s1
.c_str(), s2
.c_str(), s1
.length()) != 0) )
591 wxPuts(wxT("ERROR: copy error!"));
595 wxPuts(wxT("File was copied ok."));
601 if ( !wxRemoveFile(filename2
) )
603 wxPuts(wxT("ERROR: failed to remove the file"));
606 wxPuts(wxEmptyString
);
609 static void TestTempFile()
611 wxPuts(wxT("*** wxTempFile test ***"));
614 if ( tmpFile
.Open(wxT("test2")) && tmpFile
.Write(wxT("the answer is 42")) )
616 if ( tmpFile
.Commit() )
617 wxPuts(wxT("File committed."));
619 wxPuts(wxT("ERROR: could't commit temp file."));
621 wxRemoveFile(wxT("test2"));
624 wxPuts(wxEmptyString
);
629 // ----------------------------------------------------------------------------
631 // ----------------------------------------------------------------------------
635 #include "wx/confbase.h"
636 #include "wx/fileconf.h"
638 static const struct FileConfTestData
640 const wxChar
*name
; // value name
641 const wxChar
*value
; // the value from the file
644 { wxT("value1"), wxT("one") },
645 { wxT("value2"), wxT("two") },
646 { wxT("novalue"), wxT("default") },
649 static void TestFileConfRead()
651 wxPuts(wxT("*** testing wxFileConfig loading/reading ***"));
653 wxFileConfig
fileconf(wxT("test"), wxEmptyString
,
654 wxT("testdata.fc"), wxEmptyString
,
655 wxCONFIG_USE_RELATIVE_PATH
);
657 // test simple reading
658 wxPuts(wxT("\nReading config file:"));
659 wxString
defValue(wxT("default")), value
;
660 for ( size_t n
= 0; n
< WXSIZEOF(fcTestData
); n
++ )
662 const FileConfTestData
& data
= fcTestData
[n
];
663 value
= fileconf
.Read(data
.name
, defValue
);
664 wxPrintf(wxT("\t%s = %s "), data
.name
, value
.c_str());
665 if ( value
== data
.value
)
671 wxPrintf(wxT("(ERROR: should be %s)\n"), data
.value
);
675 // test enumerating the entries
676 wxPuts(wxT("\nEnumerating all root entries:"));
679 bool cont
= fileconf
.GetFirstEntry(name
, dummy
);
682 wxPrintf(wxT("\t%s = %s\n"),
684 fileconf
.Read(name
.c_str(), wxT("ERROR")).c_str());
686 cont
= fileconf
.GetNextEntry(name
, dummy
);
689 static const wxChar
*testEntry
= wxT("TestEntry");
690 wxPrintf(wxT("\nTesting deletion of newly created \"Test\" entry: "));
691 fileconf
.Write(testEntry
, wxT("A value"));
692 fileconf
.DeleteEntry(testEntry
);
693 wxPrintf(fileconf
.HasEntry(testEntry
) ? wxT("ERROR\n") : wxT("ok\n"));
696 #endif // TEST_FILECONF
698 // ----------------------------------------------------------------------------
700 // ----------------------------------------------------------------------------
704 #include "wx/filename.h"
707 static void DumpFileName(const wxChar
*desc
, const wxFileName
& fn
)
711 wxString full
= fn
.GetFullPath();
713 wxString vol
, path
, name
, ext
;
714 wxFileName::SplitPath(full
, &vol
, &path
, &name
, &ext
);
716 wxPrintf(wxT("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
717 full
.c_str(), vol
.c_str(), path
.c_str(), name
.c_str(), ext
.c_str());
719 wxFileName::SplitPath(full
, &path
, &name
, &ext
);
720 wxPrintf(wxT("or\t\t-> path '%s', name '%s', ext '%s'\n"),
721 path
.c_str(), name
.c_str(), ext
.c_str());
723 wxPrintf(wxT("path is also:\t'%s'\n"), fn
.GetPath().c_str());
724 wxPrintf(wxT("with volume: \t'%s'\n"),
725 fn
.GetPath(wxPATH_GET_VOLUME
).c_str());
726 wxPrintf(wxT("with separator:\t'%s'\n"),
727 fn
.GetPath(wxPATH_GET_SEPARATOR
).c_str());
728 wxPrintf(wxT("with both: \t'%s'\n"),
729 fn
.GetPath(wxPATH_GET_SEPARATOR
| wxPATH_GET_VOLUME
).c_str());
731 wxPuts(wxT("The directories in the path are:"));
732 wxArrayString dirs
= fn
.GetDirs();
733 size_t count
= dirs
.GetCount();
734 for ( size_t n
= 0; n
< count
; n
++ )
736 wxPrintf(wxT("\t%u: %s\n"), n
, dirs
[n
].c_str());
741 static void TestFileNameTemp()
743 wxPuts(wxT("*** testing wxFileName temp file creation ***"));
745 static const wxChar
*tmpprefixes
[] =
753 wxT("/tmp/foo/bar"), // this one must be an error
757 for ( size_t n
= 0; n
< WXSIZEOF(tmpprefixes
); n
++ )
759 wxString path
= wxFileName::CreateTempFileName(tmpprefixes
[n
]);
762 // "error" is not in upper case because it may be ok
763 wxPrintf(wxT("Prefix '%s'\t-> error\n"), tmpprefixes
[n
]);
767 wxPrintf(wxT("Prefix '%s'\t-> temp file '%s'\n"),
768 tmpprefixes
[n
], path
.c_str());
770 if ( !wxRemoveFile(path
) )
772 wxLogWarning(wxT("Failed to remove temp file '%s'"),
779 static void TestFileNameDirManip()
781 // TODO: test AppendDir(), RemoveDir(), ...
784 static void TestFileNameComparison()
789 static void TestFileNameOperations()
794 static void TestFileNameCwd()
799 #endif // TEST_FILENAME
801 // ----------------------------------------------------------------------------
802 // wxFileName time functions
803 // ----------------------------------------------------------------------------
807 #include "wx/filename.h"
808 #include "wx/datetime.h"
810 static void TestFileGetTimes()
812 wxFileName
fn(wxT("testdata.fc"));
814 wxDateTime dtAccess
, dtMod
, dtCreate
;
815 if ( !fn
.GetTimes(&dtAccess
, &dtMod
, &dtCreate
) )
817 wxPrintf(wxT("ERROR: GetTimes() failed.\n"));
821 static const wxChar
*fmt
= wxT("%Y-%b-%d %H:%M:%S");
823 wxPrintf(wxT("File times for '%s':\n"), fn
.GetFullPath().c_str());
824 wxPrintf(wxT("Creation: \t%s\n"), dtCreate
.Format(fmt
).c_str());
825 wxPrintf(wxT("Last read: \t%s\n"), dtAccess
.Format(fmt
).c_str());
826 wxPrintf(wxT("Last write: \t%s\n"), dtMod
.Format(fmt
).c_str());
831 static void TestFileSetTimes()
833 wxFileName
fn(wxT("testdata.fc"));
837 wxPrintf(wxT("ERROR: Touch() failed.\n"));
842 #endif // TEST_FILETIME
844 // ----------------------------------------------------------------------------
846 // ----------------------------------------------------------------------------
851 #include "wx/utils.h" // for wxSetEnv
853 static wxLocale gs_localeDefault
;
854 // NOTE: don't init it here as it needs a wxAppTraits object
855 // and thus must be init-ed after creation of the wxInitializer
856 // class in the main()
858 // find the name of the language from its value
859 static const wxChar
*GetLangName(int lang
)
861 static const wxChar
*languageNames
[] =
871 wxT("ARABIC_ALGERIA"),
872 wxT("ARABIC_BAHRAIN"),
875 wxT("ARABIC_JORDAN"),
876 wxT("ARABIC_KUWAIT"),
877 wxT("ARABIC_LEBANON"),
879 wxT("ARABIC_MOROCCO"),
882 wxT("ARABIC_SAUDI_ARABIA"),
885 wxT("ARABIC_TUNISIA"),
892 wxT("AZERI_CYRILLIC"),
907 wxT("CHINESE_SIMPLIFIED"),
908 wxT("CHINESE_TRADITIONAL"),
909 wxT("CHINESE_HONGKONG"),
910 wxT("CHINESE_MACAU"),
911 wxT("CHINESE_SINGAPORE"),
912 wxT("CHINESE_TAIWAN"),
918 wxT("DUTCH_BELGIAN"),
922 wxT("ENGLISH_AUSTRALIA"),
923 wxT("ENGLISH_BELIZE"),
924 wxT("ENGLISH_BOTSWANA"),
925 wxT("ENGLISH_CANADA"),
926 wxT("ENGLISH_CARIBBEAN"),
927 wxT("ENGLISH_DENMARK"),
929 wxT("ENGLISH_JAMAICA"),
930 wxT("ENGLISH_NEW_ZEALAND"),
931 wxT("ENGLISH_PHILIPPINES"),
932 wxT("ENGLISH_SOUTH_AFRICA"),
933 wxT("ENGLISH_TRINIDAD"),
934 wxT("ENGLISH_ZIMBABWE"),
942 wxT("FRENCH_BELGIAN"),
943 wxT("FRENCH_CANADIAN"),
944 wxT("FRENCH_LUXEMBOURG"),
945 wxT("FRENCH_MONACO"),
951 wxT("GERMAN_AUSTRIAN"),
952 wxT("GERMAN_BELGIUM"),
953 wxT("GERMAN_LIECHTENSTEIN"),
954 wxT("GERMAN_LUXEMBOURG"),
972 wxT("ITALIAN_SWISS"),
977 wxT("KASHMIRI_INDIA"),
995 wxT("MALAY_BRUNEI_DARUSSALAM"),
996 wxT("MALAY_MALAYSIA"),
1005 wxT("NEPALI_INDIA"),
1006 wxT("NORWEGIAN_BOKMAL"),
1007 wxT("NORWEGIAN_NYNORSK"),
1014 wxT("PORTUGUESE_BRAZILIAN"),
1017 wxT("RHAETO_ROMANCE"),
1020 wxT("RUSSIAN_UKRAINE"),
1024 wxT("SCOTS_GAELIC"),
1026 wxT("SERBIAN_CYRILLIC"),
1027 wxT("SERBIAN_LATIN"),
1028 wxT("SERBO_CROATIAN"),
1039 wxT("SPANISH_ARGENTINA"),
1040 wxT("SPANISH_BOLIVIA"),
1041 wxT("SPANISH_CHILE"),
1042 wxT("SPANISH_COLOMBIA"),
1043 wxT("SPANISH_COSTA_RICA"),
1044 wxT("SPANISH_DOMINICAN_REPUBLIC"),
1045 wxT("SPANISH_ECUADOR"),
1046 wxT("SPANISH_EL_SALVADOR"),
1047 wxT("SPANISH_GUATEMALA"),
1048 wxT("SPANISH_HONDURAS"),
1049 wxT("SPANISH_MEXICAN"),
1050 wxT("SPANISH_MODERN"),
1051 wxT("SPANISH_NICARAGUA"),
1052 wxT("SPANISH_PANAMA"),
1053 wxT("SPANISH_PARAGUAY"),
1054 wxT("SPANISH_PERU"),
1055 wxT("SPANISH_PUERTO_RICO"),
1056 wxT("SPANISH_URUGUAY"),
1058 wxT("SPANISH_VENEZUELA"),
1062 wxT("SWEDISH_FINLAND"),
1080 wxT("URDU_PAKISTAN"),
1082 wxT("UZBEK_CYRILLIC"),
1095 if ( (size_t)lang
< WXSIZEOF(languageNames
) )
1096 return languageNames
[lang
];
1098 return wxT("INVALID");
1101 static void TestDefaultLang()
1103 wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
1105 gs_localeDefault
.Init(wxLANGUAGE_ENGLISH
);
1107 static const wxChar
*langStrings
[] =
1109 NULL
, // system default
1116 wxT("de_DE.iso88591"),
1118 wxT("?"), // invalid lang spec
1119 wxT("klingonese"), // I bet on some systems it does exist...
1122 wxPrintf(wxT("The default system encoding is %s (%d)\n"),
1123 wxLocale::GetSystemEncodingName().c_str(),
1124 wxLocale::GetSystemEncoding());
1126 for ( size_t n
= 0; n
< WXSIZEOF(langStrings
); n
++ )
1128 const wxChar
*langStr
= langStrings
[n
];
1131 // FIXME: this doesn't do anything at all under Windows, we need
1132 // to create a new wxLocale!
1133 wxSetEnv(wxT("LC_ALL"), langStr
);
1136 int lang
= gs_localeDefault
.GetSystemLanguage();
1137 wxPrintf(wxT("Locale for '%s' is %s.\n"),
1138 langStr
? langStr
: wxT("system default"), GetLangName(lang
));
1142 #endif // TEST_LOCALE
1144 // ----------------------------------------------------------------------------
1146 // ----------------------------------------------------------------------------
1150 #include "wx/mimetype.h"
1152 static void TestMimeEnum()
1154 wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1156 wxArrayString mimetypes
;
1158 size_t count
= wxTheMimeTypesManager
->EnumAllFileTypes(mimetypes
);
1160 wxPrintf(wxT("*** All %u known filetypes: ***\n"), count
);
1165 for ( size_t n
= 0; n
< count
; n
++ )
1167 wxFileType
*filetype
=
1168 wxTheMimeTypesManager
->GetFileTypeFromMimeType(mimetypes
[n
]);
1171 wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
1172 mimetypes
[n
].c_str());
1176 filetype
->GetDescription(&desc
);
1177 filetype
->GetExtensions(exts
);
1179 filetype
->GetIcon(NULL
);
1182 for ( size_t e
= 0; e
< exts
.GetCount(); e
++ )
1185 extsAll
<< wxT(", ");
1189 wxPrintf(wxT("\t%s: %s (%s)\n"),
1190 mimetypes
[n
].c_str(), desc
.c_str(), extsAll
.c_str());
1193 wxPuts(wxEmptyString
);
1196 static void TestMimeFilename()
1198 wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
1200 static const wxChar
*filenames
[] =
1203 wxT("document.pdf"),
1205 wxT("picture.jpeg"),
1208 for ( size_t n
= 0; n
< WXSIZEOF(filenames
); n
++ )
1210 const wxString fname
= filenames
[n
];
1211 wxString ext
= fname
.AfterLast(wxT('.'));
1212 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
1215 wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext
.c_str());
1220 if ( !ft
->GetDescription(&desc
) )
1221 desc
= wxT("<no description>");
1224 if ( !ft
->GetOpenCommand(&cmd
,
1225 wxFileType::MessageParameters(fname
, wxEmptyString
)) )
1226 cmd
= wxT("<no command available>");
1228 cmd
= wxString(wxT('"')) + cmd
+ wxT('"');
1230 wxPrintf(wxT("To open %s (%s) do %s.\n"),
1231 fname
.c_str(), desc
.c_str(), cmd
.c_str());
1237 wxPuts(wxEmptyString
);
1240 // these tests were broken by wxMimeTypesManager changes, temporarily disabling
1243 static void TestMimeOverride()
1245 wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
1247 static const wxChar
*mailcap
= wxT("/tmp/mailcap");
1248 static const wxChar
*mimetypes
= wxT("/tmp/mime.types");
1250 if ( wxFile::Exists(mailcap
) )
1251 wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
1253 wxTheMimeTypesManager
->ReadMailcap(mailcap
) ? wxT("ok") : wxT("ERROR"));
1255 wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1258 if ( wxFile::Exists(mimetypes
) )
1259 wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
1261 wxTheMimeTypesManager
->ReadMimeTypes(mimetypes
) ? wxT("ok") : wxT("ERROR"));
1263 wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1266 wxPuts(wxEmptyString
);
1269 static void TestMimeAssociate()
1271 wxPuts(wxT("*** Testing creation of filetype association ***\n"));
1273 wxFileTypeInfo
ftInfo(
1274 wxT("application/x-xyz"),
1275 wxT("xyzview '%s'"), // open cmd
1276 wxT(""), // print cmd
1277 wxT("XYZ File"), // description
1278 wxT(".xyz"), // extensions
1279 wxNullPtr
// end of extensions
1281 ftInfo
.SetShortDesc(wxT("XYZFile")); // used under Win32 only
1283 wxFileType
*ft
= wxTheMimeTypesManager
->Associate(ftInfo
);
1286 wxPuts(wxT("ERROR: failed to create association!"));
1290 // TODO: read it back
1294 wxPuts(wxEmptyString
);
1301 // ----------------------------------------------------------------------------
1302 // module dependencies feature
1303 // ----------------------------------------------------------------------------
1307 #include "wx/module.h"
1309 class wxTestModule
: public wxModule
1312 virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1313 virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1316 class wxTestModuleA
: public wxTestModule
1321 DECLARE_DYNAMIC_CLASS(wxTestModuleA
)
1324 class wxTestModuleB
: public wxTestModule
1329 DECLARE_DYNAMIC_CLASS(wxTestModuleB
)
1332 class wxTestModuleC
: public wxTestModule
1337 DECLARE_DYNAMIC_CLASS(wxTestModuleC
)
1340 class wxTestModuleD
: public wxTestModule
1345 DECLARE_DYNAMIC_CLASS(wxTestModuleD
)
1348 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC
, wxModule
)
1349 wxTestModuleC::wxTestModuleC()
1351 AddDependency(CLASSINFO(wxTestModuleD
));
1354 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA
, wxModule
)
1355 wxTestModuleA::wxTestModuleA()
1357 AddDependency(CLASSINFO(wxTestModuleB
));
1358 AddDependency(CLASSINFO(wxTestModuleD
));
1361 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD
, wxModule
)
1362 wxTestModuleD::wxTestModuleD()
1366 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB
, wxModule
)
1367 wxTestModuleB::wxTestModuleB()
1369 AddDependency(CLASSINFO(wxTestModuleD
));
1370 AddDependency(CLASSINFO(wxTestModuleC
));
1373 #endif // TEST_MODULE
1375 // ----------------------------------------------------------------------------
1376 // misc information functions
1377 // ----------------------------------------------------------------------------
1379 #ifdef TEST_INFO_FUNCTIONS
1381 #include "wx/utils.h"
1383 #if TEST_INTERACTIVE
1384 static void TestDiskInfo()
1386 wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
1390 wxChar pathname
[128];
1391 wxPrintf(wxT("\nEnter a directory name: "));
1392 if ( !wxFgets(pathname
, WXSIZEOF(pathname
), stdin
) )
1395 // kill the last '\n'
1396 pathname
[wxStrlen(pathname
) - 1] = 0;
1398 wxLongLong total
, free
;
1399 if ( !wxGetDiskSpace(pathname
, &total
, &free
) )
1401 wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
1405 wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
1406 (total
/ 1024).ToString().c_str(),
1407 (free
/ 1024).ToString().c_str(),
1412 #endif // TEST_INTERACTIVE
1414 static void TestOsInfo()
1416 wxPuts(wxT("*** Testing OS info functions ***\n"));
1419 wxGetOsVersion(&major
, &minor
);
1420 wxPrintf(wxT("Running under: %s, version %d.%d\n"),
1421 wxGetOsDescription().c_str(), major
, minor
);
1423 wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1425 wxPrintf(wxT("Host name is %s (%s).\n"),
1426 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1428 wxPuts(wxEmptyString
);
1431 static void TestPlatformInfo()
1433 wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
1435 // get this platform
1436 wxPlatformInfo plat
;
1438 wxPrintf(wxT("Operating system family name is: %s\n"), plat
.GetOperatingSystemFamilyName().c_str());
1439 wxPrintf(wxT("Operating system name is: %s\n"), plat
.GetOperatingSystemIdName().c_str());
1440 wxPrintf(wxT("Port ID name is: %s\n"), plat
.GetPortIdName().c_str());
1441 wxPrintf(wxT("Port ID short name is: %s\n"), plat
.GetPortIdShortName().c_str());
1442 wxPrintf(wxT("Architecture is: %s\n"), plat
.GetArchName().c_str());
1443 wxPrintf(wxT("Endianness is: %s\n"), plat
.GetEndiannessName().c_str());
1445 wxPuts(wxEmptyString
);
1448 static void TestUserInfo()
1450 wxPuts(wxT("*** Testing user info functions ***\n"));
1452 wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
1453 wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
1454 wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1455 wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1457 wxPuts(wxEmptyString
);
1460 #endif // TEST_INFO_FUNCTIONS
1462 // ----------------------------------------------------------------------------
1464 // ----------------------------------------------------------------------------
1466 #ifdef TEST_PATHLIST
1469 #define CMD_IN_PATH wxT("ls")
1471 #define CMD_IN_PATH wxT("command.com")
1474 static void TestPathList()
1476 wxPuts(wxT("*** Testing wxPathList ***\n"));
1478 wxPathList pathlist
;
1479 pathlist
.AddEnvList(wxT("PATH"));
1480 wxString path
= pathlist
.FindValidPath(CMD_IN_PATH
);
1483 wxPrintf(wxT("ERROR: command not found in the path.\n"));
1487 wxPrintf(wxT("Command found in the path as '%s'.\n"), path
.c_str());
1491 #endif // TEST_PATHLIST
1493 // ----------------------------------------------------------------------------
1494 // regular expressions
1495 // ----------------------------------------------------------------------------
1497 #if defined TEST_REGEX && TEST_INTERACTIVE
1499 #include "wx/regex.h"
1501 static void TestRegExInteractive()
1503 wxPuts(wxT("*** Testing RE interactively ***"));
1507 wxChar pattern
[128];
1508 wxPrintf(wxT("\nEnter a pattern: "));
1509 if ( !wxFgets(pattern
, WXSIZEOF(pattern
), stdin
) )
1512 // kill the last '\n'
1513 pattern
[wxStrlen(pattern
) - 1] = 0;
1516 if ( !re
.Compile(pattern
) )
1524 wxPrintf(wxT("Enter text to match: "));
1525 if ( !wxFgets(text
, WXSIZEOF(text
), stdin
) )
1528 // kill the last '\n'
1529 text
[wxStrlen(text
) - 1] = 0;
1531 if ( !re
.Matches(text
) )
1533 wxPrintf(wxT("No match.\n"));
1537 wxPrintf(wxT("Pattern matches at '%s'\n"), re
.GetMatch(text
).c_str());
1540 for ( size_t n
= 1; ; n
++ )
1542 if ( !re
.GetMatch(&start
, &len
, n
) )
1547 wxPrintf(wxT("Subexpr %u matched '%s'\n"),
1548 n
, wxString(text
+ start
, len
).c_str());
1555 #endif // TEST_REGEX
1557 // ----------------------------------------------------------------------------
1559 // ----------------------------------------------------------------------------
1562 NB: this stuff was taken from the glibc test suite and modified to build
1563 in wxWidgets: if I read the copyright below properly, this shouldn't
1569 #ifdef wxTEST_PRINTF
1570 // use our functions from wxchar.cpp
1574 // NB: do _not_ use WX_ATTRIBUTE_PRINTF here, we have some invalid formats
1575 // in the tests below
1576 int wxPrintf( const wxChar
*format
, ... );
1577 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... );
1580 #include "wx/longlong.h"
1584 static void rfg1 (void);
1585 static void rfg2 (void);
1589 fmtchk (const wxChar
*fmt
)
1591 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1592 (void) wxPrintf(fmt
, 0x12);
1593 (void) wxPrintf(wxT("'\n"));
1597 fmtst1chk (const wxChar
*fmt
)
1599 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1600 (void) wxPrintf(fmt
, 4, 0x12);
1601 (void) wxPrintf(wxT("'\n"));
1605 fmtst2chk (const wxChar
*fmt
)
1607 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1608 (void) wxPrintf(fmt
, 4, 4, 0x12);
1609 (void) wxPrintf(wxT("'\n"));
1612 /* This page is covered by the following copyright: */
1614 /* (C) Copyright C E Chew
1616 * Feel free to copy, use and distribute this software provided:
1618 * 1. you do not pretend that you wrote it
1619 * 2. you leave this copyright notice intact.
1623 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1630 /* Formatted Output Test
1632 * This exercises the output formatting code.
1635 wxChar
*PointerNull
= NULL
;
1642 wxChar
*prefix
= buf
;
1645 wxPuts(wxT("\nFormatted output test"));
1646 wxPrintf(wxT("prefix 6d 6o 6x 6X 6u\n"));
1647 wxStrcpy(prefix
, wxT("%"));
1648 for (i
= 0; i
< 2; i
++) {
1649 for (j
= 0; j
< 2; j
++) {
1650 for (k
= 0; k
< 2; k
++) {
1651 for (l
= 0; l
< 2; l
++) {
1652 wxStrcpy(prefix
, wxT("%"));
1653 if (i
== 0) wxStrcat(prefix
, wxT("-"));
1654 if (j
== 0) wxStrcat(prefix
, wxT("+"));
1655 if (k
== 0) wxStrcat(prefix
, wxT("#"));
1656 if (l
== 0) wxStrcat(prefix
, wxT("0"));
1657 wxPrintf(wxT("%5s |"), prefix
);
1658 wxStrcpy(tp
, prefix
);
1659 wxStrcat(tp
, wxT("6d |"));
1661 wxStrcpy(tp
, prefix
);
1662 wxStrcat(tp
, wxT("6o |"));
1664 wxStrcpy(tp
, prefix
);
1665 wxStrcat(tp
, wxT("6x |"));
1667 wxStrcpy(tp
, prefix
);
1668 wxStrcat(tp
, wxT("6X |"));
1670 wxStrcpy(tp
, prefix
);
1671 wxStrcat(tp
, wxT("6u |"));
1673 wxPrintf(wxT("\n"));
1678 wxPrintf(wxT("%10s\n"), PointerNull
);
1679 wxPrintf(wxT("%-10s\n"), PointerNull
);
1682 static void TestPrintf()
1684 static wxChar shortstr
[] = wxT("Hi, Z.");
1685 static wxChar longstr
[] = wxT("Good morning, Doctor Chandra. This is Hal. \
1686 I am ready for my first lesson today.");
1688 wxString test_format
;
1690 fmtchk(wxT("%.4x"));
1691 fmtchk(wxT("%04x"));
1692 fmtchk(wxT("%4.4x"));
1693 fmtchk(wxT("%04.4x"));
1694 fmtchk(wxT("%4.3x"));
1695 fmtchk(wxT("%04.3x"));
1697 fmtst1chk(wxT("%.*x"));
1698 fmtst1chk(wxT("%0*x"));
1699 fmtst2chk(wxT("%*.*x"));
1700 fmtst2chk(wxT("%0*.*x"));
1702 wxString bad_format
= wxT("bad format:\t\"%b\"\n");
1703 wxPrintf(bad_format
.c_str());
1704 wxPrintf(wxT("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL
);
1706 wxPrintf(wxT("decimal negative:\t\"%d\"\n"), -2345);
1707 wxPrintf(wxT("octal negative:\t\"%o\"\n"), -2345);
1708 wxPrintf(wxT("hex negative:\t\"%x\"\n"), -2345);
1709 wxPrintf(wxT("long decimal number:\t\"%ld\"\n"), -123456L);
1710 wxPrintf(wxT("long octal negative:\t\"%lo\"\n"), -2345L);
1711 wxPrintf(wxT("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
1712 wxPrintf(wxT("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
1713 test_format
= wxT("left-adjusted ZLDN:\t\"%-010ld\"\n");
1714 wxPrintf(test_format
.c_str(), -123456);
1715 wxPrintf(wxT("space-padded LDN:\t\"%10ld\"\n"), -123456L);
1716 wxPrintf(wxT("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
1718 test_format
= wxT("zero-padded string:\t\"%010s\"\n");
1719 wxPrintf(test_format
.c_str(), shortstr
);
1720 test_format
= wxT("left-adjusted Z string:\t\"%-010s\"\n");
1721 wxPrintf(test_format
.c_str(), shortstr
);
1722 wxPrintf(wxT("space-padded string:\t\"%10s\"\n"), shortstr
);
1723 wxPrintf(wxT("left-adjusted S string:\t\"%-10s\"\n"), shortstr
);
1724 wxPrintf(wxT("null string:\t\"%s\"\n"), PointerNull
);
1725 wxPrintf(wxT("limited string:\t\"%.22s\"\n"), longstr
);
1727 wxPrintf(wxT("e-style >= 1:\t\"%e\"\n"), 12.34);
1728 wxPrintf(wxT("e-style >= .1:\t\"%e\"\n"), 0.1234);
1729 wxPrintf(wxT("e-style < .1:\t\"%e\"\n"), 0.001234);
1730 wxPrintf(wxT("e-style big:\t\"%.60e\"\n"), 1e20
);
1731 wxPrintf(wxT("e-style == .1:\t\"%e\"\n"), 0.1);
1732 wxPrintf(wxT("f-style >= 1:\t\"%f\"\n"), 12.34);
1733 wxPrintf(wxT("f-style >= .1:\t\"%f\"\n"), 0.1234);
1734 wxPrintf(wxT("f-style < .1:\t\"%f\"\n"), 0.001234);
1735 wxPrintf(wxT("g-style >= 1:\t\"%g\"\n"), 12.34);
1736 wxPrintf(wxT("g-style >= .1:\t\"%g\"\n"), 0.1234);
1737 wxPrintf(wxT("g-style < .1:\t\"%g\"\n"), 0.001234);
1738 wxPrintf(wxT("g-style big:\t\"%.60g\"\n"), 1e20
);
1740 wxPrintf (wxT(" %6.5f\n"), .099999999860301614);
1741 wxPrintf (wxT(" %6.5f\n"), .1);
1742 wxPrintf (wxT("x%5.4fx\n"), .5);
1744 wxPrintf (wxT("%#03x\n"), 1);
1746 //wxPrintf (wxT("something really insane: %.10000f\n"), 1.0);
1752 while (niter
-- != 0)
1753 wxPrintf (wxT("%.17e\n"), d
/ 2);
1758 // Open Watcom cause compiler error here
1759 // Error! E173: col(24) floating-point constant too small to represent
1760 wxPrintf (wxT("%15.5e\n"), 4.9406564584124654e-324);
1763 #define FORMAT wxT("|%12.4f|%12.4e|%12.4g|\n")
1764 wxPrintf (FORMAT
, 0.0, 0.0, 0.0);
1765 wxPrintf (FORMAT
, 1.0, 1.0, 1.0);
1766 wxPrintf (FORMAT
, -1.0, -1.0, -1.0);
1767 wxPrintf (FORMAT
, 100.0, 100.0, 100.0);
1768 wxPrintf (FORMAT
, 1000.0, 1000.0, 1000.0);
1769 wxPrintf (FORMAT
, 10000.0, 10000.0, 10000.0);
1770 wxPrintf (FORMAT
, 12345.0, 12345.0, 12345.0);
1771 wxPrintf (FORMAT
, 100000.0, 100000.0, 100000.0);
1772 wxPrintf (FORMAT
, 123456.0, 123456.0, 123456.0);
1777 int rc
= wxSnprintf (buf
, WXSIZEOF(buf
), wxT("%30s"), wxT("foo"));
1779 wxPrintf(wxT("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1780 rc
, WXSIZEOF(buf
), buf
);
1783 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1784 wxSnprintf(buf2
, WXSIZEOFbuf2
), "%.999999u", 10));
1790 wxPrintf (wxT("%e should be 1.234568e+06\n"), 1234567.8);
1791 wxPrintf (wxT("%f should be 1234567.800000\n"), 1234567.8);
1792 wxPrintf (wxT("%g should be 1.23457e+06\n"), 1234567.8);
1793 wxPrintf (wxT("%g should be 123.456\n"), 123.456);
1794 wxPrintf (wxT("%g should be 1e+06\n"), 1000000.0);
1795 wxPrintf (wxT("%g should be 10\n"), 10.0);
1796 wxPrintf (wxT("%g should be 0.02\n"), 0.02);
1800 wxPrintf(wxT("%.17f\n"),(1.0/x
/10.0+1.0)*x
-x
);
1806 wxSprintf(buf
,wxT("%*s%*s%*s"),-1,wxT("one"),-20,wxT("two"),-30,wxT("three"));
1808 result
|= wxStrcmp (buf
,
1809 wxT("onetwo three "));
1811 wxPuts (result
!= 0 ? wxT("Test failed!") : wxT("Test ok."));
1818 wxSprintf(buf
, "%07" wxLongLongFmtSpec
"o", wxLL(040000000000));
1820 // for some reason below line fails under Borland
1821 wxPrintf (wxT("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf
);
1824 if (wxStrcmp (buf
, wxT("40000000000")) != 0)
1827 wxPuts (wxT("\tFAILED"));
1829 wxUnusedVar(result
);
1830 wxPuts (wxEmptyString
);
1832 #endif // wxLongLong_t
1834 wxPrintf (wxT("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX
+ 2, UCHAR_MAX
+ 2);
1835 wxPrintf (wxT("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX
+ 2, USHRT_MAX
+ 2);
1837 wxPuts (wxT("--- Should be no further output. ---"));
1846 memset (bytes
, '\xff', sizeof bytes
);
1847 wxSprintf (buf
, wxT("foo%hhn\n"), &bytes
[3]);
1848 if (bytes
[0] != '\xff' || bytes
[1] != '\xff' || bytes
[2] != '\xff'
1849 || bytes
[4] != '\xff' || bytes
[5] != '\xff' || bytes
[6] != '\xff')
1851 wxPuts (wxT("%hhn overwrite more bytes"));
1856 wxPuts (wxT("%hhn wrote incorrect value"));
1868 wxSprintf (buf
, wxT("%5.s"), wxT("xyz"));
1869 if (wxStrcmp (buf
, wxT(" ")) != 0)
1870 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" "));
1871 wxSprintf (buf
, wxT("%5.f"), 33.3);
1872 if (wxStrcmp (buf
, wxT(" 33")) != 0)
1873 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 33"));
1874 wxSprintf (buf
, wxT("%8.e"), 33.3e7
);
1875 if (wxStrcmp (buf
, wxT(" 3e+08")) != 0)
1876 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3e+08"));
1877 wxSprintf (buf
, wxT("%8.E"), 33.3e7
);
1878 if (wxStrcmp (buf
, wxT(" 3E+08")) != 0)
1879 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3E+08"));
1880 wxSprintf (buf
, wxT("%.g"), 33.3);
1881 if (wxStrcmp (buf
, wxT("3e+01")) != 0)
1882 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3e+01"));
1883 wxSprintf (buf
, wxT("%.G"), 33.3);
1884 if (wxStrcmp (buf
, wxT("3E+01")) != 0)
1885 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3E+01"));
1893 wxString test_format
;
1896 wxSprintf (buf
, wxT("%.*g"), prec
, 3.3);
1897 if (wxStrcmp (buf
, wxT("3")) != 0)
1898 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
1900 wxSprintf (buf
, wxT("%.*G"), prec
, 3.3);
1901 if (wxStrcmp (buf
, wxT("3")) != 0)
1902 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
1904 wxSprintf (buf
, wxT("%7.*G"), prec
, 3.33);
1905 if (wxStrcmp (buf
, wxT(" 3")) != 0)
1906 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3"));
1908 test_format
= wxT("%04.*o");
1909 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1910 if (wxStrcmp (buf
, wxT(" 041")) != 0)
1911 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 041"));
1913 test_format
= wxT("%09.*u");
1914 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1915 if (wxStrcmp (buf
, wxT(" 0000033")) != 0)
1916 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 0000033"));
1918 test_format
= wxT("%04.*x");
1919 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1920 if (wxStrcmp (buf
, wxT(" 021")) != 0)
1921 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
1923 test_format
= wxT("%04.*X");
1924 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1925 if (wxStrcmp (buf
, wxT(" 021")) != 0)
1926 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
1929 #endif // TEST_PRINTF
1931 // ----------------------------------------------------------------------------
1932 // registry and related stuff
1933 // ----------------------------------------------------------------------------
1935 // this is for MSW only
1938 #undef TEST_REGISTRY
1943 #include "wx/confbase.h"
1944 #include "wx/msw/regconf.h"
1947 static void TestRegConfWrite()
1949 wxConfig
*config
= new wxConfig(wxT("myapp"));
1950 config
->SetPath(wxT("/group1"));
1951 config
->Write(wxT("entry1"), wxT("foo"));
1952 config
->SetPath(wxT("/group2"));
1953 config
->Write(wxT("entry1"), wxT("bar"));
1957 static void TestRegConfRead()
1959 wxRegConfig
*config
= new wxRegConfig(wxT("myapp"));
1963 config
->SetPath(wxT("/"));
1964 wxPuts(wxT("Enumerating / subgroups:"));
1965 bool bCont
= config
->GetFirstGroup(str
, dummy
);
1969 bCont
= config
->GetNextGroup(str
, dummy
);
1973 #endif // TEST_REGCONF
1975 #ifdef TEST_REGISTRY
1977 #include "wx/msw/registry.h"
1979 // I chose this one because I liked its name, but it probably only exists under
1981 static const wxChar
*TESTKEY
=
1982 wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
1984 static void TestRegistryRead()
1986 wxPuts(wxT("*** testing registry reading ***"));
1988 wxRegKey
key(TESTKEY
);
1989 wxPrintf(wxT("The test key name is '%s'.\n"), key
.GetName().c_str());
1992 wxPuts(wxT("ERROR: test key can't be opened, aborting test."));
1997 size_t nSubKeys
, nValues
;
1998 if ( key
.GetKeyInfo(&nSubKeys
, NULL
, &nValues
, NULL
) )
2000 wxPrintf(wxT("It has %u subkeys and %u values.\n"), nSubKeys
, nValues
);
2003 wxPrintf(wxT("Enumerating values:\n"));
2007 bool cont
= key
.GetFirstValue(value
, dummy
);
2010 wxPrintf(wxT("Value '%s': type "), value
.c_str());
2011 switch ( key
.GetValueType(value
) )
2013 case wxRegKey::Type_None
: wxPrintf(wxT("ERROR (none)")); break;
2014 case wxRegKey::Type_String
: wxPrintf(wxT("SZ")); break;
2015 case wxRegKey::Type_Expand_String
: wxPrintf(wxT("EXPAND_SZ")); break;
2016 case wxRegKey::Type_Binary
: wxPrintf(wxT("BINARY")); break;
2017 case wxRegKey::Type_Dword
: wxPrintf(wxT("DWORD")); break;
2018 case wxRegKey::Type_Multi_String
: wxPrintf(wxT("MULTI_SZ")); break;
2019 default: wxPrintf(wxT("other (unknown)")); break;
2022 wxPrintf(wxT(", value = "));
2023 if ( key
.IsNumericValue(value
) )
2026 key
.QueryValue(value
, &val
);
2027 wxPrintf(wxT("%ld"), val
);
2032 key
.QueryValue(value
, val
);
2033 wxPrintf(wxT("'%s'"), val
.c_str());
2035 key
.QueryRawValue(value
, val
);
2036 wxPrintf(wxT(" (raw value '%s')"), val
.c_str());
2041 cont
= key
.GetNextValue(value
, dummy
);
2045 static void TestRegistryAssociation()
2048 The second call to deleteself genertaes an error message, with a
2049 messagebox saying .flo is crucial to system operation, while the .ddf
2050 call also fails, but with no error message
2055 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2057 key
= wxT("ddxf_auto_file") ;
2058 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2060 key
= wxT("ddxf_auto_file") ;
2061 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2063 key
= wxT("program,0") ;
2064 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2066 key
= wxT("program \"%1\"") ;
2068 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2070 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2072 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2074 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2078 #endif // TEST_REGISTRY
2080 // ----------------------------------------------------------------------------
2082 // ----------------------------------------------------------------------------
2084 #ifdef TEST_SCOPEGUARD
2086 #include "wx/scopeguard.h"
2088 static void function0() { puts("function0()"); }
2089 static void function1(int n
) { printf("function1(%d)\n", n
); }
2090 static void function2(double x
, char c
) { printf("function2(%g, %c)\n", x
, c
); }
2094 void method0() { printf("method0()\n"); }
2095 void method1(int n
) { printf("method1(%d)\n", n
); }
2096 void method2(double x
, char c
) { printf("method2(%g, %c)\n", x
, c
); }
2099 static void TestScopeGuard()
2101 wxON_BLOCK_EXIT0(function0
);
2102 wxON_BLOCK_EXIT1(function1
, 17);
2103 wxON_BLOCK_EXIT2(function2
, 3.14, 'p');
2106 wxON_BLOCK_EXIT_OBJ0(obj
, Object::method0
);
2107 wxON_BLOCK_EXIT_OBJ1(obj
, Object::method1
, 7);
2108 wxON_BLOCK_EXIT_OBJ2(obj
, Object::method2
, 2.71, 'e');
2110 wxScopeGuard dismissed
= wxMakeGuard(function0
);
2111 dismissed
.Dismiss();
2116 // ----------------------------------------------------------------------------
2118 // ----------------------------------------------------------------------------
2122 #include "wx/protocol/ftp.h"
2123 #include "wx/protocol/log.h"
2125 #define FTP_ANONYMOUS
2129 #ifdef FTP_ANONYMOUS
2130 static const wxChar
*hostname
= wxT("ftp.wxwidgets.org");
2131 static const wxChar
*directory
= wxT("/pub");
2132 static const wxChar
*filename
= wxT("welcome.msg");
2134 static const wxChar
*hostname
= "localhost";
2135 static const wxChar
*directory
= wxT("/etc");
2136 static const wxChar
*filename
= wxT("issue");
2139 static bool TestFtpConnect()
2141 wxPuts(wxT("*** Testing FTP connect ***"));
2143 #ifdef FTP_ANONYMOUS
2144 wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname
);
2145 #else // !FTP_ANONYMOUS
2147 wxFgets(user
, WXSIZEOF(user
), stdin
);
2148 user
[wxStrlen(user
) - 1] = '\0'; // chop off '\n'
2151 wxChar password
[256];
2152 wxPrintf(wxT("Password for %s: "), password
);
2153 wxFgets(password
, WXSIZEOF(password
), stdin
);
2154 password
[wxStrlen(password
) - 1] = '\0'; // chop off '\n'
2155 ftp
->SetPassword(password
);
2157 wxPrintf(wxT("--- Attempting to connect to %s:21 as %s...\n"), hostname
, user
);
2158 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2160 if ( !ftp
->Connect(hostname
) )
2162 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname
);
2168 wxPrintf(wxT("--- Connected to %s, current directory is '%s'\n"),
2169 hostname
, ftp
->Pwd().c_str());
2176 #if TEST_INTERACTIVE
2177 static void TestFtpInteractive()
2179 wxPuts(wxT("\n*** Interactive wxFTP test ***"));
2185 wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
2186 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2189 // kill the last '\n'
2190 buf
[wxStrlen(buf
) - 1] = 0;
2192 // special handling of LIST and NLST as they require data connection
2193 wxString
start(buf
, 4);
2195 if ( start
== wxT("LIST") || start
== wxT("NLST") )
2198 if ( wxStrlen(buf
) > 4 )
2201 wxArrayString files
;
2202 if ( !ftp
->GetList(files
, wildcard
, start
== wxT("LIST")) )
2204 wxPrintf(wxT("ERROR: failed to get %s of files\n"), start
.c_str());
2208 wxPrintf(wxT("--- %s of '%s' under '%s':\n"),
2209 start
.c_str(), wildcard
.c_str(), ftp
->Pwd().c_str());
2210 size_t count
= files
.GetCount();
2211 for ( size_t n
= 0; n
< count
; n
++ )
2213 wxPrintf(wxT("\t%s\n"), files
[n
].c_str());
2215 wxPuts(wxT("--- End of the file list"));
2218 else if ( start
== wxT("QUIT") )
2220 break; // get out of here!
2224 wxChar ch
= ftp
->SendCommand(buf
);
2225 wxPrintf(wxT("Command %s"), ch
? wxT("succeeded") : wxT("failed"));
2228 wxPrintf(wxT(" (return code %c)"), ch
);
2231 wxPrintf(wxT(", server reply:\n%s\n\n"), ftp
->GetLastResult().c_str());
2237 #endif // TEST_INTERACTIVE
2240 // ----------------------------------------------------------------------------
2242 // ----------------------------------------------------------------------------
2244 #ifdef TEST_STACKWALKER
2246 #if wxUSE_STACKWALKER
2248 #include "wx/stackwalk.h"
2250 class StackDump
: public wxStackWalker
2253 StackDump(const char *argv0
)
2254 : wxStackWalker(argv0
)
2258 virtual void Walk(size_t skip
= 1, size_t maxdepth
= wxSTACKWALKER_MAX_DEPTH
)
2260 wxPuts(wxT("Stack dump:"));
2262 wxStackWalker::Walk(skip
, maxdepth
);
2266 virtual void OnStackFrame(const wxStackFrame
& frame
)
2268 printf("[%2d] ", (int) frame
.GetLevel());
2270 wxString name
= frame
.GetName();
2271 if ( !name
.empty() )
2273 printf("%-20.40s", (const char*)name
.mb_str());
2277 printf("0x%08lx", (unsigned long)frame
.GetAddress());
2280 if ( frame
.HasSourceLocation() )
2283 (const char*)frame
.GetFileName().mb_str(),
2284 (int)frame
.GetLine());
2290 for ( size_t n
= 0; frame
.GetParam(n
, &type
, &name
, &val
); n
++ )
2292 printf("\t%s %s = %s\n", (const char*)type
.mb_str(),
2293 (const char*)name
.mb_str(),
2294 (const char*)val
.mb_str());
2299 static void TestStackWalk(const char *argv0
)
2301 wxPuts(wxT("*** Testing wxStackWalker ***"));
2303 StackDump
dump(argv0
);
2309 #endif // wxUSE_STACKWALKER
2311 #endif // TEST_STACKWALKER
2313 // ----------------------------------------------------------------------------
2315 // ----------------------------------------------------------------------------
2317 #ifdef TEST_STDPATHS
2319 #include "wx/stdpaths.h"
2320 #include "wx/wxchar.h" // wxPrintf
2322 static void TestStandardPaths()
2324 wxPuts(wxT("*** Testing wxStandardPaths ***"));
2326 wxTheApp
->SetAppName(wxT("console"));
2328 wxStandardPathsBase
& stdp
= wxStandardPaths::Get();
2329 wxPrintf(wxT("Config dir (sys):\t%s\n"), stdp
.GetConfigDir().c_str());
2330 wxPrintf(wxT("Config dir (user):\t%s\n"), stdp
.GetUserConfigDir().c_str());
2331 wxPrintf(wxT("Data dir (sys):\t\t%s\n"), stdp
.GetDataDir().c_str());
2332 wxPrintf(wxT("Data dir (sys local):\t%s\n"), stdp
.GetLocalDataDir().c_str());
2333 wxPrintf(wxT("Data dir (user):\t%s\n"), stdp
.GetUserDataDir().c_str());
2334 wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp
.GetUserLocalDataDir().c_str());
2335 wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp
.GetDocumentsDir().c_str());
2336 wxPrintf(wxT("Executable path:\t%s\n"), stdp
.GetExecutablePath().c_str());
2337 wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp
.GetPluginsDir().c_str());
2338 wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp
.GetResourcesDir().c_str());
2339 wxPrintf(wxT("Localized res. dir:\t%s\n"),
2340 stdp
.GetLocalizedResourcesDir(wxT("fr")).c_str());
2341 wxPrintf(wxT("Message catalogs dir:\t%s\n"),
2342 stdp
.GetLocalizedResourcesDir
2345 wxStandardPaths::ResourceCat_Messages
2351 #endif // TEST_STDPATHS
2353 // ----------------------------------------------------------------------------
2355 // ----------------------------------------------------------------------------
2357 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
2363 #include "wx/volume.h"
2365 static const wxChar
*volumeKinds
[] =
2371 wxT("network volume"),
2372 wxT("other volume"),
2375 static void TestFSVolume()
2377 wxPuts(wxT("*** Testing wxFSVolume class ***"));
2379 wxArrayString volumes
= wxFSVolume::GetVolumes();
2380 size_t count
= volumes
.GetCount();
2384 wxPuts(wxT("ERROR: no mounted volumes?"));
2388 wxPrintf(wxT("%u mounted volumes found:\n"), count
);
2390 for ( size_t n
= 0; n
< count
; n
++ )
2392 wxFSVolume
vol(volumes
[n
]);
2395 wxPuts(wxT("ERROR: couldn't create volume"));
2399 wxPrintf(wxT("%u: %s (%s), %s, %s, %s\n"),
2401 vol
.GetDisplayName().c_str(),
2402 vol
.GetName().c_str(),
2403 volumeKinds
[vol
.GetKind()],
2404 vol
.IsWritable() ? wxT("rw") : wxT("ro"),
2405 vol
.GetFlags() & wxFS_VOL_REMOVABLE
? wxT("removable")
2412 #endif // TEST_VOLUME
2414 // ----------------------------------------------------------------------------
2416 // ----------------------------------------------------------------------------
2418 #ifdef TEST_DATETIME
2420 #include "wx/math.h"
2421 #include "wx/datetime.h"
2423 #if TEST_INTERACTIVE
2425 static void TestDateTimeInteractive()
2427 wxPuts(wxT("\n*** interactive wxDateTime tests ***"));
2433 wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
2434 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2437 // kill the last '\n'
2438 buf
[wxStrlen(buf
) - 1] = 0;
2440 if ( wxString(buf
).CmpNoCase("quit") == 0 )
2444 const wxChar
*p
= dt
.ParseDate(buf
);
2447 wxPrintf(wxT("ERROR: failed to parse the date '%s'.\n"), buf
);
2453 wxPrintf(wxT("WARNING: parsed only first %u characters.\n"), p
- buf
);
2456 wxPrintf(wxT("%s: day %u, week of month %u/%u, week of year %u\n"),
2457 dt
.Format(wxT("%b %d, %Y")).c_str(),
2459 dt
.GetWeekOfMonth(wxDateTime::Monday_First
),
2460 dt
.GetWeekOfMonth(wxDateTime::Sunday_First
),
2461 dt
.GetWeekOfYear(wxDateTime::Monday_First
));
2467 #endif // TEST_INTERACTIVE
2468 #endif // TEST_DATETIME
2470 // ----------------------------------------------------------------------------
2472 // ----------------------------------------------------------------------------
2474 #ifdef TEST_SNGLINST
2476 #include "wx/snglinst.h"
2478 static bool TestSingleIstance()
2480 wxPuts(wxT("\n*** Testing wxSingleInstanceChecker ***"));
2482 wxSingleInstanceChecker checker
;
2483 if ( checker
.Create(wxT(".wxconsole.lock")) )
2485 if ( checker
.IsAnotherRunning() )
2487 wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
2492 // wait some time to give time to launch another instance
2493 wxPuts(wxT("If you try to run another instance of this program now, it won't start."));
2494 wxPrintf(wxT("Press \"Enter\" to exit wxSingleInstanceChecker test and proceed..."));
2497 else // failed to create
2499 wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
2506 #endif // TEST_SNGLINST
2509 // ----------------------------------------------------------------------------
2511 // ----------------------------------------------------------------------------
2513 int main(int argc
, char **argv
)
2516 wxChar
**wxArgv
= new wxChar
*[argc
+ 1];
2521 for (n
= 0; n
< argc
; n
++ )
2523 wxMB2WXbuf warg
= wxConvertMB2WX(argv
[n
]);
2524 wxArgv
[n
] = wxStrdup(warg
);
2529 #else // !wxUSE_UNICODE
2531 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
2533 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE
, "program");
2535 wxInitializer initializer
;
2538 fprintf(stderr
, "Failed to initialize the wxWidgets library, aborting.");
2543 #ifdef TEST_SNGLINST
2544 if (!TestSingleIstance())
2546 #endif // TEST_SNGLINST
2558 TestDllListLoaded();
2559 #endif // TEST_DYNLIB
2563 #endif // TEST_ENVIRON
2565 #ifdef TEST_FILECONF
2567 #endif // TEST_FILECONF
2571 #endif // TEST_LOCALE
2574 wxPuts(wxT("*** Testing wxLog ***"));
2577 for ( size_t n
= 0; n
< 8000; n
++ )
2579 s
<< (wxChar
)(wxT('A') + (n
% 26));
2582 wxLogWarning(wxT("The length of the string is %lu"),
2583 (unsigned long)s
.length());
2586 msg
.Printf(wxT("A very very long message: '%s', the end!\n"), s
.c_str());
2588 // this one shouldn't be truncated
2591 // but this one will because log functions use fixed size buffer
2592 // (note that it doesn't need '\n' at the end neither - will be added
2594 wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s
.c_str());
2604 #ifdef TEST_FILENAME
2607 TestFileNameDirManip();
2608 TestFileNameComparison();
2609 TestFileNameOperations();
2610 #endif // TEST_FILENAME
2612 #ifdef TEST_FILETIME
2617 #endif // TEST_FILETIME
2620 wxLog::AddTraceMask(FTP_TRACE_MASK
);
2622 // wxFTP cannot be a static variable as its ctor needs to access
2623 // wxWidgets internals after it has been initialized
2625 ftp
->SetLog(new wxProtocolLog(FTP_TRACE_MASK
));
2626 if ( TestFtpConnect() )
2627 TestFtpInteractive();
2628 //else: connecting to the FTP server failed
2634 //wxLog::AddTraceMask(wxT("mime"));
2638 TestMimeAssociate();
2643 #ifdef TEST_INFO_FUNCTIONS
2648 #if TEST_INTERACTIVE
2651 #endif // TEST_INFO_FUNCTIONS
2653 #ifdef TEST_PATHLIST
2655 #endif // TEST_PATHLIST
2659 #endif // TEST_PRINTF
2666 #endif // TEST_REGCONF
2668 #if defined TEST_REGEX && TEST_INTERACTIVE
2669 TestRegExInteractive();
2670 #endif // defined TEST_REGEX && TEST_INTERACTIVE
2672 #ifdef TEST_REGISTRY
2674 TestRegistryAssociation();
2675 #endif // TEST_REGISTRY
2677 #ifdef TEST_DATETIME
2678 #if TEST_INTERACTIVE
2679 TestDateTimeInteractive();
2681 #endif // TEST_DATETIME
2683 #ifdef TEST_SCOPEGUARD
2687 #ifdef TEST_STACKWALKER
2688 #if wxUSE_STACKWALKER
2689 TestStackWalk(argv
[0]);
2691 #endif // TEST_STACKWALKER
2693 #ifdef TEST_STDPATHS
2694 TestStandardPaths();
2698 wxPuts(wxT("Sleeping for 3 seconds... z-z-z-z-z..."));
2700 #endif // TEST_USLEEP
2704 #endif // TEST_VOLUME
2708 for ( int n
= 0; n
< argc
; n
++ )
2713 #endif // wxUSE_UNICODE