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 #else // #if TEST_ALL
127 #define TEST_DATETIME
129 #define TEST_STDPATHS
130 #define TEST_STACKWALKER
132 #define TEST_SNGLINST
135 // some tests are interactive, define this to run them
136 #ifdef TEST_INTERACTIVE
137 #undef TEST_INTERACTIVE
139 #define TEST_INTERACTIVE 1
141 #define TEST_INTERACTIVE 1
144 // ============================================================================
146 // ============================================================================
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
157 static const wxChar
*ROOTDIR
= wxT("/");
158 static const wxChar
*TESTDIR
= wxT("/usr/local/share");
159 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
160 static const wxChar
*ROOTDIR
= wxT("c:\\");
161 static const wxChar
*TESTDIR
= wxT("d:\\");
163 #error "don't know where the root directory is"
166 static void TestDirEnumHelper(wxDir
& dir
,
167 int flags
= wxDIR_DEFAULT
,
168 const wxString
& filespec
= wxEmptyString
)
172 if ( !dir
.IsOpened() )
175 bool cont
= dir
.GetFirst(&filename
, filespec
, flags
);
178 wxPrintf(wxT("\t%s\n"), filename
.c_str());
180 cont
= dir
.GetNext(&filename
);
183 wxPuts(wxEmptyString
);
188 static void TestDirEnum()
190 wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
192 wxString cwd
= wxGetCwd();
193 if ( !wxDir::Exists(cwd
) )
195 wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd
.c_str());
200 if ( !dir
.IsOpened() )
202 wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd
.c_str());
206 wxPuts(wxT("Enumerating everything in current directory:"));
207 TestDirEnumHelper(dir
);
209 wxPuts(wxT("Enumerating really everything in current directory:"));
210 TestDirEnumHelper(dir
, wxDIR_DEFAULT
| wxDIR_DOTDOT
);
212 wxPuts(wxT("Enumerating object files in current directory:"));
213 TestDirEnumHelper(dir
, wxDIR_DEFAULT
, wxT("*.o*"));
215 wxPuts(wxT("Enumerating directories in current directory:"));
216 TestDirEnumHelper(dir
, wxDIR_DIRS
);
218 wxPuts(wxT("Enumerating files in current directory:"));
219 TestDirEnumHelper(dir
, wxDIR_FILES
);
221 wxPuts(wxT("Enumerating files including hidden in current directory:"));
222 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
226 wxPuts(wxT("Enumerating everything in root directory:"));
227 TestDirEnumHelper(dir
, wxDIR_DEFAULT
);
229 wxPuts(wxT("Enumerating directories in root directory:"));
230 TestDirEnumHelper(dir
, wxDIR_DIRS
);
232 wxPuts(wxT("Enumerating files in root directory:"));
233 TestDirEnumHelper(dir
, wxDIR_FILES
);
235 wxPuts(wxT("Enumerating files including hidden in root directory:"));
236 TestDirEnumHelper(dir
, wxDIR_FILES
| wxDIR_HIDDEN
);
238 wxPuts(wxT("Enumerating files in non existing directory:"));
239 wxDir
dirNo(wxT("nosuchdir"));
240 TestDirEnumHelper(dirNo
);
245 class DirPrintTraverser
: public wxDirTraverser
248 virtual wxDirTraverseResult
OnFile(const wxString
& WXUNUSED(filename
))
250 return wxDIR_CONTINUE
;
253 virtual wxDirTraverseResult
OnDir(const wxString
& dirname
)
255 wxString path
, name
, ext
;
256 wxFileName::SplitPath(dirname
, &path
, &name
, &ext
);
259 name
<< wxT('.') << ext
;
262 for ( const wxChar
*p
= path
.c_str(); *p
; p
++ )
264 if ( wxIsPathSeparator(*p
) )
268 wxPrintf(wxT("%s%s\n"), indent
.c_str(), name
.c_str());
270 return wxDIR_CONTINUE
;
274 static void TestDirTraverse()
276 wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
280 size_t n
= wxDir::GetAllFiles(TESTDIR
, &files
);
281 wxPrintf(wxT("There are %u files under '%s'\n"), n
, TESTDIR
);
284 wxPrintf(wxT("First one is '%s'\n"), files
[0u].c_str());
285 wxPrintf(wxT(" last one is '%s'\n"), files
[n
- 1].c_str());
288 // enum again with custom traverser
289 wxPuts(wxT("Now enumerating directories:"));
291 DirPrintTraverser traverser
;
292 dir
.Traverse(traverser
, wxEmptyString
, wxDIR_DIRS
| wxDIR_HIDDEN
);
297 static void TestDirExists()
299 wxPuts(wxT("*** Testing wxDir::Exists() ***"));
301 static const wxChar
*dirnames
[] =
304 #if defined(__WXMSW__)
307 wxT("\\\\share\\file"),
311 wxT("c:\\autoexec.bat"),
312 #elif defined(__UNIX__)
321 for ( size_t n
= 0; n
< WXSIZEOF(dirnames
); n
++ )
323 wxPrintf(wxT("%-40s: %s\n"),
325 wxDir::Exists(dirnames
[n
]) ? wxT("exists")
326 : wxT("doesn't exist"));
334 // ----------------------------------------------------------------------------
336 // ----------------------------------------------------------------------------
340 #include "wx/dynlib.h"
342 static void TestDllLoad()
344 #if defined(__WXMSW__)
345 static const wxChar
*LIB_NAME
= wxT("kernel32.dll");
346 static const wxChar
*FUNC_NAME
= wxT("lstrlenA");
347 #elif defined(__UNIX__)
348 // weird: using just libc.so does *not* work!
349 static const wxChar
*LIB_NAME
= wxT("/lib/libc.so.6");
350 static const wxChar
*FUNC_NAME
= wxT("strlen");
352 #error "don't know how to test wxDllLoader on this platform"
355 wxPuts(wxT("*** testing basic wxDynamicLibrary functions ***\n"));
357 wxDynamicLibrary
lib(LIB_NAME
);
358 if ( !lib
.IsLoaded() )
360 wxPrintf(wxT("ERROR: failed to load '%s'.\n"), LIB_NAME
);
364 typedef int (wxSTDCALL
*wxStrlenType
)(const char *);
365 wxStrlenType pfnStrlen
= (wxStrlenType
)lib
.GetSymbol(FUNC_NAME
);
368 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
369 FUNC_NAME
, LIB_NAME
);
373 wxPrintf(wxT("Calling %s dynamically loaded from %s "),
374 FUNC_NAME
, LIB_NAME
);
376 if ( pfnStrlen("foo") != 3 )
378 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
382 wxPuts(wxT("... ok"));
387 static const wxChar
*FUNC_NAME_AW
= wxT("lstrlen");
389 typedef int (wxSTDCALL
*wxStrlenTypeAorW
)(const wxChar
*);
391 pfnStrlenAorW
= (wxStrlenTypeAorW
)lib
.GetSymbolAorW(FUNC_NAME_AW
);
392 if ( !pfnStrlenAorW
)
394 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
395 FUNC_NAME_AW
, LIB_NAME
);
399 if ( pfnStrlenAorW(wxT("foobar")) != 6 )
401 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
408 #if defined(__WXMSW__) || defined(__UNIX__)
410 static void TestDllListLoaded()
412 wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
414 puts("\nLoaded modules:");
415 wxDynamicLibraryDetailsArray dlls
= wxDynamicLibrary::ListLoaded();
416 const size_t count
= dlls
.GetCount();
417 for ( size_t n
= 0; n
< count
; ++n
)
419 const wxDynamicLibraryDetails
& details
= dlls
[n
];
420 printf("%-45s", (const char *)details
.GetPath().mb_str());
422 void *addr
wxDUMMY_INITIALIZE(NULL
);
423 size_t len
wxDUMMY_INITIALIZE(0);
424 if ( details
.GetAddress(&addr
, &len
) )
426 printf(" %08lx:%08lx",
427 (unsigned long)addr
, (unsigned long)((char *)addr
+ len
));
430 printf(" %s\n", (const char *)details
.GetVersion().mb_str());
436 #endif // TEST_DYNLIB
438 // ----------------------------------------------------------------------------
440 // ----------------------------------------------------------------------------
444 #include "wx/utils.h"
446 static wxString
MyGetEnv(const wxString
& var
)
449 if ( !wxGetEnv(var
, &val
) )
450 val
= wxT("<empty>");
452 val
= wxString(wxT('\'')) + val
+ wxT('\'');
457 static void TestEnvironment()
459 const wxChar
*var
= wxT("wxTestVar");
461 wxPuts(wxT("*** testing environment access functions ***"));
463 wxPrintf(wxT("Initially getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
464 wxSetEnv(var
, wxT("value for wxTestVar"));
465 wxPrintf(wxT("After wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
466 wxSetEnv(var
, wxT("another value"));
467 wxPrintf(wxT("After 2nd wxSetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
469 wxPrintf(wxT("After wxUnsetEnv: getenv(%s) = %s\n"), var
, MyGetEnv(var
).c_str());
470 wxPrintf(wxT("PATH = %s\n"), MyGetEnv(wxT("PATH")).c_str());
473 #endif // TEST_ENVIRON
475 // ----------------------------------------------------------------------------
477 // ----------------------------------------------------------------------------
482 #include "wx/ffile.h"
483 #include "wx/textfile.h"
485 static void TestFileRead()
487 wxPuts(wxT("*** wxFile read test ***"));
489 wxFile
file(wxT("testdata.fc"));
490 if ( file
.IsOpened() )
492 wxPrintf(wxT("File length: %lu\n"), file
.Length());
494 wxPuts(wxT("File dump:\n----------"));
496 static const size_t len
= 1024;
500 size_t nRead
= file
.Read(buf
, len
);
501 if ( nRead
== (size_t)wxInvalidOffset
)
503 wxPrintf(wxT("Failed to read the file."));
507 fwrite(buf
, nRead
, 1, stdout
);
513 wxPuts(wxT("----------"));
517 wxPrintf(wxT("ERROR: can't open test file.\n"));
520 wxPuts(wxEmptyString
);
523 static void TestTextFileRead()
525 wxPuts(wxT("*** wxTextFile read test ***"));
527 wxTextFile
file(wxT("testdata.fc"));
530 wxPrintf(wxT("Number of lines: %u\n"), file
.GetLineCount());
531 wxPrintf(wxT("Last line: '%s'\n"), file
.GetLastLine().c_str());
535 wxPuts(wxT("\nDumping the entire file:"));
536 for ( s
= file
.GetFirstLine(); !file
.Eof(); s
= file
.GetNextLine() )
538 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
540 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
542 wxPuts(wxT("\nAnd now backwards:"));
543 for ( s
= file
.GetLastLine();
544 file
.GetCurrentLine() != 0;
545 s
= file
.GetPrevLine() )
547 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
549 wxPrintf(wxT("%6u: %s\n"), file
.GetCurrentLine() + 1, s
.c_str());
553 wxPrintf(wxT("ERROR: can't open '%s'\n"), file
.GetName());
556 wxPuts(wxEmptyString
);
559 static void TestFileCopy()
561 wxPuts(wxT("*** Testing wxCopyFile ***"));
563 static const wxChar
*filename1
= wxT("testdata.fc");
564 static const wxChar
*filename2
= wxT("test2");
565 if ( !wxCopyFile(filename1
, filename2
) )
567 wxPuts(wxT("ERROR: failed to copy file"));
571 wxFFile
f1(filename1
, wxT("rb")),
572 f2(filename2
, wxT("rb"));
574 if ( !f1
.IsOpened() || !f2
.IsOpened() )
576 wxPuts(wxT("ERROR: failed to open file(s)"));
581 if ( !f1
.ReadAll(&s1
) || !f2
.ReadAll(&s2
) )
583 wxPuts(wxT("ERROR: failed to read file(s)"));
587 if ( (s1
.length() != s2
.length()) ||
588 (memcmp(s1
.c_str(), s2
.c_str(), s1
.length()) != 0) )
590 wxPuts(wxT("ERROR: copy error!"));
594 wxPuts(wxT("File was copied ok."));
600 if ( !wxRemoveFile(filename2
) )
602 wxPuts(wxT("ERROR: failed to remove the file"));
605 wxPuts(wxEmptyString
);
608 static void TestTempFile()
610 wxPuts(wxT("*** wxTempFile test ***"));
613 if ( tmpFile
.Open(wxT("test2")) && tmpFile
.Write(wxT("the answer is 42")) )
615 if ( tmpFile
.Commit() )
616 wxPuts(wxT("File committed."));
618 wxPuts(wxT("ERROR: could't commit temp file."));
620 wxRemoveFile(wxT("test2"));
623 wxPuts(wxEmptyString
);
628 // ----------------------------------------------------------------------------
630 // ----------------------------------------------------------------------------
634 #include "wx/confbase.h"
635 #include "wx/fileconf.h"
637 static const struct FileConfTestData
639 const wxChar
*name
; // value name
640 const wxChar
*value
; // the value from the file
643 { wxT("value1"), wxT("one") },
644 { wxT("value2"), wxT("two") },
645 { wxT("novalue"), wxT("default") },
648 static void TestFileConfRead()
650 wxPuts(wxT("*** testing wxFileConfig loading/reading ***"));
652 wxFileConfig
fileconf(wxT("test"), wxEmptyString
,
653 wxT("testdata.fc"), wxEmptyString
,
654 wxCONFIG_USE_RELATIVE_PATH
);
656 // test simple reading
657 wxPuts(wxT("\nReading config file:"));
658 wxString
defValue(wxT("default")), value
;
659 for ( size_t n
= 0; n
< WXSIZEOF(fcTestData
); n
++ )
661 const FileConfTestData
& data
= fcTestData
[n
];
662 value
= fileconf
.Read(data
.name
, defValue
);
663 wxPrintf(wxT("\t%s = %s "), data
.name
, value
.c_str());
664 if ( value
== data
.value
)
670 wxPrintf(wxT("(ERROR: should be %s)\n"), data
.value
);
674 // test enumerating the entries
675 wxPuts(wxT("\nEnumerating all root entries:"));
678 bool cont
= fileconf
.GetFirstEntry(name
, dummy
);
681 wxPrintf(wxT("\t%s = %s\n"),
683 fileconf
.Read(name
.c_str(), wxT("ERROR")).c_str());
685 cont
= fileconf
.GetNextEntry(name
, dummy
);
688 static const wxChar
*testEntry
= wxT("TestEntry");
689 wxPrintf(wxT("\nTesting deletion of newly created \"Test\" entry: "));
690 fileconf
.Write(testEntry
, wxT("A value"));
691 fileconf
.DeleteEntry(testEntry
);
692 wxPrintf(fileconf
.HasEntry(testEntry
) ? wxT("ERROR\n") : wxT("ok\n"));
695 #endif // TEST_FILECONF
697 // ----------------------------------------------------------------------------
699 // ----------------------------------------------------------------------------
703 #include "wx/filename.h"
706 static void DumpFileName(const wxChar
*desc
, const wxFileName
& fn
)
710 wxString full
= fn
.GetFullPath();
712 wxString vol
, path
, name
, ext
;
713 wxFileName::SplitPath(full
, &vol
, &path
, &name
, &ext
);
715 wxPrintf(wxT("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
716 full
.c_str(), vol
.c_str(), path
.c_str(), name
.c_str(), ext
.c_str());
718 wxFileName::SplitPath(full
, &path
, &name
, &ext
);
719 wxPrintf(wxT("or\t\t-> path '%s', name '%s', ext '%s'\n"),
720 path
.c_str(), name
.c_str(), ext
.c_str());
722 wxPrintf(wxT("path is also:\t'%s'\n"), fn
.GetPath().c_str());
723 wxPrintf(wxT("with volume: \t'%s'\n"),
724 fn
.GetPath(wxPATH_GET_VOLUME
).c_str());
725 wxPrintf(wxT("with separator:\t'%s'\n"),
726 fn
.GetPath(wxPATH_GET_SEPARATOR
).c_str());
727 wxPrintf(wxT("with both: \t'%s'\n"),
728 fn
.GetPath(wxPATH_GET_SEPARATOR
| wxPATH_GET_VOLUME
).c_str());
730 wxPuts(wxT("The directories in the path are:"));
731 wxArrayString dirs
= fn
.GetDirs();
732 size_t count
= dirs
.GetCount();
733 for ( size_t n
= 0; n
< count
; n
++ )
735 wxPrintf(wxT("\t%u: %s\n"), n
, dirs
[n
].c_str());
740 static void TestFileNameTemp()
742 wxPuts(wxT("*** testing wxFileName temp file creation ***"));
744 static const wxChar
*tmpprefixes
[] =
752 wxT("/tmp/foo/bar"), // this one must be an error
756 for ( size_t n
= 0; n
< WXSIZEOF(tmpprefixes
); n
++ )
758 wxString path
= wxFileName::CreateTempFileName(tmpprefixes
[n
]);
761 // "error" is not in upper case because it may be ok
762 wxPrintf(wxT("Prefix '%s'\t-> error\n"), tmpprefixes
[n
]);
766 wxPrintf(wxT("Prefix '%s'\t-> temp file '%s'\n"),
767 tmpprefixes
[n
], path
.c_str());
769 if ( !wxRemoveFile(path
) )
771 wxLogWarning(wxT("Failed to remove temp file '%s'"),
778 static void TestFileNameDirManip()
780 // TODO: test AppendDir(), RemoveDir(), ...
783 static void TestFileNameComparison()
788 static void TestFileNameOperations()
793 static void TestFileNameCwd()
798 #endif // TEST_FILENAME
800 // ----------------------------------------------------------------------------
801 // wxFileName time functions
802 // ----------------------------------------------------------------------------
806 #include "wx/filename.h"
807 #include "wx/datetime.h"
809 static void TestFileGetTimes()
811 wxFileName
fn(wxT("testdata.fc"));
813 wxDateTime dtAccess
, dtMod
, dtCreate
;
814 if ( !fn
.GetTimes(&dtAccess
, &dtMod
, &dtCreate
) )
816 wxPrintf(wxT("ERROR: GetTimes() failed.\n"));
820 static const wxChar
*fmt
= wxT("%Y-%b-%d %H:%M:%S");
822 wxPrintf(wxT("File times for '%s':\n"), fn
.GetFullPath().c_str());
823 wxPrintf(wxT("Creation: \t%s\n"), dtCreate
.Format(fmt
).c_str());
824 wxPrintf(wxT("Last read: \t%s\n"), dtAccess
.Format(fmt
).c_str());
825 wxPrintf(wxT("Last write: \t%s\n"), dtMod
.Format(fmt
).c_str());
830 static void TestFileSetTimes()
832 wxFileName
fn(wxT("testdata.fc"));
836 wxPrintf(wxT("ERROR: Touch() failed.\n"));
841 #endif // TEST_FILETIME
843 // ----------------------------------------------------------------------------
845 // ----------------------------------------------------------------------------
850 #include "wx/utils.h" // for wxSetEnv
852 static wxLocale gs_localeDefault
;
853 // NOTE: don't init it here as it needs a wxAppTraits object
854 // and thus must be init-ed after creation of the wxInitializer
855 // class in the main()
857 // find the name of the language from its value
858 static const wxChar
*GetLangName(int lang
)
860 static const wxChar
*languageNames
[] =
870 wxT("ARABIC_ALGERIA"),
871 wxT("ARABIC_BAHRAIN"),
874 wxT("ARABIC_JORDAN"),
875 wxT("ARABIC_KUWAIT"),
876 wxT("ARABIC_LEBANON"),
878 wxT("ARABIC_MOROCCO"),
881 wxT("ARABIC_SAUDI_ARABIA"),
884 wxT("ARABIC_TUNISIA"),
891 wxT("AZERI_CYRILLIC"),
906 wxT("CHINESE_SIMPLIFIED"),
907 wxT("CHINESE_TRADITIONAL"),
908 wxT("CHINESE_HONGKONG"),
909 wxT("CHINESE_MACAU"),
910 wxT("CHINESE_SINGAPORE"),
911 wxT("CHINESE_TAIWAN"),
917 wxT("DUTCH_BELGIAN"),
921 wxT("ENGLISH_AUSTRALIA"),
922 wxT("ENGLISH_BELIZE"),
923 wxT("ENGLISH_BOTSWANA"),
924 wxT("ENGLISH_CANADA"),
925 wxT("ENGLISH_CARIBBEAN"),
926 wxT("ENGLISH_DENMARK"),
928 wxT("ENGLISH_JAMAICA"),
929 wxT("ENGLISH_NEW_ZEALAND"),
930 wxT("ENGLISH_PHILIPPINES"),
931 wxT("ENGLISH_SOUTH_AFRICA"),
932 wxT("ENGLISH_TRINIDAD"),
933 wxT("ENGLISH_ZIMBABWE"),
941 wxT("FRENCH_BELGIAN"),
942 wxT("FRENCH_CANADIAN"),
943 wxT("FRENCH_LUXEMBOURG"),
944 wxT("FRENCH_MONACO"),
950 wxT("GERMAN_AUSTRIAN"),
951 wxT("GERMAN_BELGIUM"),
952 wxT("GERMAN_LIECHTENSTEIN"),
953 wxT("GERMAN_LUXEMBOURG"),
971 wxT("ITALIAN_SWISS"),
976 wxT("KASHMIRI_INDIA"),
994 wxT("MALAY_BRUNEI_DARUSSALAM"),
995 wxT("MALAY_MALAYSIA"),
1004 wxT("NEPALI_INDIA"),
1005 wxT("NORWEGIAN_BOKMAL"),
1006 wxT("NORWEGIAN_NYNORSK"),
1013 wxT("PORTUGUESE_BRAZILIAN"),
1016 wxT("RHAETO_ROMANCE"),
1019 wxT("RUSSIAN_UKRAINE"),
1023 wxT("SCOTS_GAELIC"),
1025 wxT("SERBIAN_CYRILLIC"),
1026 wxT("SERBIAN_LATIN"),
1027 wxT("SERBO_CROATIAN"),
1038 wxT("SPANISH_ARGENTINA"),
1039 wxT("SPANISH_BOLIVIA"),
1040 wxT("SPANISH_CHILE"),
1041 wxT("SPANISH_COLOMBIA"),
1042 wxT("SPANISH_COSTA_RICA"),
1043 wxT("SPANISH_DOMINICAN_REPUBLIC"),
1044 wxT("SPANISH_ECUADOR"),
1045 wxT("SPANISH_EL_SALVADOR"),
1046 wxT("SPANISH_GUATEMALA"),
1047 wxT("SPANISH_HONDURAS"),
1048 wxT("SPANISH_MEXICAN"),
1049 wxT("SPANISH_MODERN"),
1050 wxT("SPANISH_NICARAGUA"),
1051 wxT("SPANISH_PANAMA"),
1052 wxT("SPANISH_PARAGUAY"),
1053 wxT("SPANISH_PERU"),
1054 wxT("SPANISH_PUERTO_RICO"),
1055 wxT("SPANISH_URUGUAY"),
1057 wxT("SPANISH_VENEZUELA"),
1061 wxT("SWEDISH_FINLAND"),
1079 wxT("URDU_PAKISTAN"),
1081 wxT("UZBEK_CYRILLIC"),
1094 if ( (size_t)lang
< WXSIZEOF(languageNames
) )
1095 return languageNames
[lang
];
1097 return wxT("INVALID");
1100 static void TestDefaultLang()
1102 wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
1104 gs_localeDefault
.Init(wxLANGUAGE_ENGLISH
);
1106 static const wxChar
*langStrings
[] =
1108 NULL
, // system default
1115 wxT("de_DE.iso88591"),
1117 wxT("?"), // invalid lang spec
1118 wxT("klingonese"), // I bet on some systems it does exist...
1121 wxPrintf(wxT("The default system encoding is %s (%d)\n"),
1122 wxLocale::GetSystemEncodingName().c_str(),
1123 wxLocale::GetSystemEncoding());
1125 for ( size_t n
= 0; n
< WXSIZEOF(langStrings
); n
++ )
1127 const wxChar
*langStr
= langStrings
[n
];
1130 // FIXME: this doesn't do anything at all under Windows, we need
1131 // to create a new wxLocale!
1132 wxSetEnv(wxT("LC_ALL"), langStr
);
1135 int lang
= gs_localeDefault
.GetSystemLanguage();
1136 wxPrintf(wxT("Locale for '%s' is %s.\n"),
1137 langStr
? langStr
: wxT("system default"), GetLangName(lang
));
1141 #endif // TEST_LOCALE
1143 // ----------------------------------------------------------------------------
1145 // ----------------------------------------------------------------------------
1149 #include "wx/mimetype.h"
1151 static void TestMimeEnum()
1153 wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1155 wxArrayString mimetypes
;
1157 size_t count
= wxTheMimeTypesManager
->EnumAllFileTypes(mimetypes
);
1159 wxPrintf(wxT("*** All %u known filetypes: ***\n"), count
);
1164 for ( size_t n
= 0; n
< count
; n
++ )
1166 wxFileType
*filetype
=
1167 wxTheMimeTypesManager
->GetFileTypeFromMimeType(mimetypes
[n
]);
1170 wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
1171 mimetypes
[n
].c_str());
1175 filetype
->GetDescription(&desc
);
1176 filetype
->GetExtensions(exts
);
1178 filetype
->GetIcon(NULL
);
1181 for ( size_t e
= 0; e
< exts
.GetCount(); e
++ )
1184 extsAll
<< wxT(", ");
1188 wxPrintf(wxT("\t%s: %s (%s)\n"),
1189 mimetypes
[n
].c_str(), desc
.c_str(), extsAll
.c_str());
1192 wxPuts(wxEmptyString
);
1195 static void TestMimeFilename()
1197 wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
1199 static const wxChar
*filenames
[] =
1202 wxT("document.pdf"),
1204 wxT("picture.jpeg"),
1207 for ( size_t n
= 0; n
< WXSIZEOF(filenames
); n
++ )
1209 const wxString fname
= filenames
[n
];
1210 wxString ext
= fname
.AfterLast(wxT('.'));
1211 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
1214 wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext
.c_str());
1219 if ( !ft
->GetDescription(&desc
) )
1220 desc
= wxT("<no description>");
1223 if ( !ft
->GetOpenCommand(&cmd
,
1224 wxFileType::MessageParameters(fname
, wxEmptyString
)) )
1225 cmd
= wxT("<no command available>");
1227 cmd
= wxString(wxT('"')) + cmd
+ wxT('"');
1229 wxPrintf(wxT("To open %s (%s) do %s.\n"),
1230 fname
.c_str(), desc
.c_str(), cmd
.c_str());
1236 wxPuts(wxEmptyString
);
1239 // these tests were broken by wxMimeTypesManager changes, temporarily disabling
1242 static void TestMimeOverride()
1244 wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
1246 static const wxChar
*mailcap
= wxT("/tmp/mailcap");
1247 static const wxChar
*mimetypes
= wxT("/tmp/mime.types");
1249 if ( wxFile::Exists(mailcap
) )
1250 wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
1252 wxTheMimeTypesManager
->ReadMailcap(mailcap
) ? wxT("ok") : wxT("ERROR"));
1254 wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1257 if ( wxFile::Exists(mimetypes
) )
1258 wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
1260 wxTheMimeTypesManager
->ReadMimeTypes(mimetypes
) ? wxT("ok") : wxT("ERROR"));
1262 wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1265 wxPuts(wxEmptyString
);
1268 static void TestMimeAssociate()
1270 wxPuts(wxT("*** Testing creation of filetype association ***\n"));
1272 wxFileTypeInfo
ftInfo(
1273 wxT("application/x-xyz"),
1274 wxT("xyzview '%s'"), // open cmd
1275 wxT(""), // print cmd
1276 wxT("XYZ File"), // description
1277 wxT(".xyz"), // extensions
1278 wxNullPtr
// end of extensions
1280 ftInfo
.SetShortDesc(wxT("XYZFile")); // used under Win32 only
1282 wxFileType
*ft
= wxTheMimeTypesManager
->Associate(ftInfo
);
1285 wxPuts(wxT("ERROR: failed to create association!"));
1289 // TODO: read it back
1293 wxPuts(wxEmptyString
);
1300 // ----------------------------------------------------------------------------
1301 // module dependencies feature
1302 // ----------------------------------------------------------------------------
1306 #include "wx/module.h"
1308 class wxTestModule
: public wxModule
1311 virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1312 virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1315 class wxTestModuleA
: public wxTestModule
1320 DECLARE_DYNAMIC_CLASS(wxTestModuleA
)
1323 class wxTestModuleB
: public wxTestModule
1328 DECLARE_DYNAMIC_CLASS(wxTestModuleB
)
1331 class wxTestModuleC
: public wxTestModule
1336 DECLARE_DYNAMIC_CLASS(wxTestModuleC
)
1339 class wxTestModuleD
: public wxTestModule
1344 DECLARE_DYNAMIC_CLASS(wxTestModuleD
)
1347 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC
, wxModule
)
1348 wxTestModuleC::wxTestModuleC()
1350 AddDependency(CLASSINFO(wxTestModuleD
));
1353 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA
, wxModule
)
1354 wxTestModuleA::wxTestModuleA()
1356 AddDependency(CLASSINFO(wxTestModuleB
));
1357 AddDependency(CLASSINFO(wxTestModuleD
));
1360 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD
, wxModule
)
1361 wxTestModuleD::wxTestModuleD()
1365 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB
, wxModule
)
1366 wxTestModuleB::wxTestModuleB()
1368 AddDependency(CLASSINFO(wxTestModuleD
));
1369 AddDependency(CLASSINFO(wxTestModuleC
));
1372 #endif // TEST_MODULE
1374 // ----------------------------------------------------------------------------
1375 // misc information functions
1376 // ----------------------------------------------------------------------------
1378 #ifdef TEST_INFO_FUNCTIONS
1380 #include "wx/utils.h"
1382 #if TEST_INTERACTIVE
1383 static void TestDiskInfo()
1385 wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
1389 wxChar pathname
[128];
1390 wxPrintf(wxT("\nEnter a directory name: "));
1391 if ( !wxFgets(pathname
, WXSIZEOF(pathname
), stdin
) )
1394 // kill the last '\n'
1395 pathname
[wxStrlen(pathname
) - 1] = 0;
1397 wxLongLong total
, free
;
1398 if ( !wxGetDiskSpace(pathname
, &total
, &free
) )
1400 wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
1404 wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
1405 (total
/ 1024).ToString().c_str(),
1406 (free
/ 1024).ToString().c_str(),
1411 #endif // TEST_INTERACTIVE
1413 static void TestOsInfo()
1415 wxPuts(wxT("*** Testing OS info functions ***\n"));
1418 wxGetOsVersion(&major
, &minor
);
1419 wxPrintf(wxT("Running under: %s, version %d.%d\n"),
1420 wxGetOsDescription().c_str(), major
, minor
);
1422 wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1424 wxPrintf(wxT("Host name is %s (%s).\n"),
1425 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1427 wxPuts(wxEmptyString
);
1430 static void TestPlatformInfo()
1432 wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
1434 // get this platform
1435 wxPlatformInfo plat
;
1437 wxPrintf(wxT("Operating system family name is: %s\n"), plat
.GetOperatingSystemFamilyName().c_str());
1438 wxPrintf(wxT("Operating system name is: %s\n"), plat
.GetOperatingSystemIdName().c_str());
1439 wxPrintf(wxT("Port ID name is: %s\n"), plat
.GetPortIdName().c_str());
1440 wxPrintf(wxT("Port ID short name is: %s\n"), plat
.GetPortIdShortName().c_str());
1441 wxPrintf(wxT("Architecture is: %s\n"), plat
.GetArchName().c_str());
1442 wxPrintf(wxT("Endianness is: %s\n"), plat
.GetEndiannessName().c_str());
1444 wxPuts(wxEmptyString
);
1447 static void TestUserInfo()
1449 wxPuts(wxT("*** Testing user info functions ***\n"));
1451 wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
1452 wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
1453 wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1454 wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1456 wxPuts(wxEmptyString
);
1459 #endif // TEST_INFO_FUNCTIONS
1461 // ----------------------------------------------------------------------------
1463 // ----------------------------------------------------------------------------
1465 #ifdef TEST_PATHLIST
1468 #define CMD_IN_PATH wxT("ls")
1470 #define CMD_IN_PATH wxT("command.com")
1473 static void TestPathList()
1475 wxPuts(wxT("*** Testing wxPathList ***\n"));
1477 wxPathList pathlist
;
1478 pathlist
.AddEnvList(wxT("PATH"));
1479 wxString path
= pathlist
.FindValidPath(CMD_IN_PATH
);
1482 wxPrintf(wxT("ERROR: command not found in the path.\n"));
1486 wxPrintf(wxT("Command found in the path as '%s'.\n"), path
.c_str());
1490 #endif // TEST_PATHLIST
1492 // ----------------------------------------------------------------------------
1493 // regular expressions
1494 // ----------------------------------------------------------------------------
1496 #if defined TEST_REGEX && TEST_INTERACTIVE
1498 #include "wx/regex.h"
1500 static void TestRegExInteractive()
1502 wxPuts(wxT("*** Testing RE interactively ***"));
1506 wxChar pattern
[128];
1507 wxPrintf(wxT("\nEnter a pattern: "));
1508 if ( !wxFgets(pattern
, WXSIZEOF(pattern
), stdin
) )
1511 // kill the last '\n'
1512 pattern
[wxStrlen(pattern
) - 1] = 0;
1515 if ( !re
.Compile(pattern
) )
1523 wxPrintf(wxT("Enter text to match: "));
1524 if ( !wxFgets(text
, WXSIZEOF(text
), stdin
) )
1527 // kill the last '\n'
1528 text
[wxStrlen(text
) - 1] = 0;
1530 if ( !re
.Matches(text
) )
1532 wxPrintf(wxT("No match.\n"));
1536 wxPrintf(wxT("Pattern matches at '%s'\n"), re
.GetMatch(text
).c_str());
1539 for ( size_t n
= 1; ; n
++ )
1541 if ( !re
.GetMatch(&start
, &len
, n
) )
1546 wxPrintf(wxT("Subexpr %u matched '%s'\n"),
1547 n
, wxString(text
+ start
, len
).c_str());
1554 #endif // TEST_REGEX
1556 // ----------------------------------------------------------------------------
1558 // ----------------------------------------------------------------------------
1561 NB: this stuff was taken from the glibc test suite and modified to build
1562 in wxWidgets: if I read the copyright below properly, this shouldn't
1568 #ifdef wxTEST_PRINTF
1569 // use our functions from wxchar.cpp
1573 // NB: do _not_ use WX_ATTRIBUTE_PRINTF here, we have some invalid formats
1574 // in the tests below
1575 int wxPrintf( const wxChar
*format
, ... );
1576 int wxSprintf( wxChar
*str
, const wxChar
*format
, ... );
1579 #include "wx/longlong.h"
1583 static void rfg1 (void);
1584 static void rfg2 (void);
1588 fmtchk (const wxChar
*fmt
)
1590 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1591 (void) wxPrintf(fmt
, 0x12);
1592 (void) wxPrintf(wxT("'\n"));
1596 fmtst1chk (const wxChar
*fmt
)
1598 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1599 (void) wxPrintf(fmt
, 4, 0x12);
1600 (void) wxPrintf(wxT("'\n"));
1604 fmtst2chk (const wxChar
*fmt
)
1606 (void) wxPrintf(wxT("%s:\t`"), fmt
);
1607 (void) wxPrintf(fmt
, 4, 4, 0x12);
1608 (void) wxPrintf(wxT("'\n"));
1611 /* This page is covered by the following copyright: */
1613 /* (C) Copyright C E Chew
1615 * Feel free to copy, use and distribute this software provided:
1617 * 1. you do not pretend that you wrote it
1618 * 2. you leave this copyright notice intact.
1622 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1629 /* Formatted Output Test
1631 * This exercises the output formatting code.
1634 wxChar
*PointerNull
= NULL
;
1641 wxChar
*prefix
= buf
;
1644 wxPuts(wxT("\nFormatted output test"));
1645 wxPrintf(wxT("prefix 6d 6o 6x 6X 6u\n"));
1646 wxStrcpy(prefix
, wxT("%"));
1647 for (i
= 0; i
< 2; i
++) {
1648 for (j
= 0; j
< 2; j
++) {
1649 for (k
= 0; k
< 2; k
++) {
1650 for (l
= 0; l
< 2; l
++) {
1651 wxStrcpy(prefix
, wxT("%"));
1652 if (i
== 0) wxStrcat(prefix
, wxT("-"));
1653 if (j
== 0) wxStrcat(prefix
, wxT("+"));
1654 if (k
== 0) wxStrcat(prefix
, wxT("#"));
1655 if (l
== 0) wxStrcat(prefix
, wxT("0"));
1656 wxPrintf(wxT("%5s |"), prefix
);
1657 wxStrcpy(tp
, prefix
);
1658 wxStrcat(tp
, wxT("6d |"));
1660 wxStrcpy(tp
, prefix
);
1661 wxStrcat(tp
, wxT("6o |"));
1663 wxStrcpy(tp
, prefix
);
1664 wxStrcat(tp
, wxT("6x |"));
1666 wxStrcpy(tp
, prefix
);
1667 wxStrcat(tp
, wxT("6X |"));
1669 wxStrcpy(tp
, prefix
);
1670 wxStrcat(tp
, wxT("6u |"));
1672 wxPrintf(wxT("\n"));
1677 wxPrintf(wxT("%10s\n"), PointerNull
);
1678 wxPrintf(wxT("%-10s\n"), PointerNull
);
1681 static void TestPrintf()
1683 static wxChar shortstr
[] = wxT("Hi, Z.");
1684 static wxChar longstr
[] = wxT("Good morning, Doctor Chandra. This is Hal. \
1685 I am ready for my first lesson today.");
1687 wxString test_format
;
1689 fmtchk(wxT("%.4x"));
1690 fmtchk(wxT("%04x"));
1691 fmtchk(wxT("%4.4x"));
1692 fmtchk(wxT("%04.4x"));
1693 fmtchk(wxT("%4.3x"));
1694 fmtchk(wxT("%04.3x"));
1696 fmtst1chk(wxT("%.*x"));
1697 fmtst1chk(wxT("%0*x"));
1698 fmtst2chk(wxT("%*.*x"));
1699 fmtst2chk(wxT("%0*.*x"));
1701 wxString bad_format
= wxT("bad format:\t\"%b\"\n");
1702 wxPrintf(bad_format
.c_str());
1703 wxPrintf(wxT("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL
);
1705 wxPrintf(wxT("decimal negative:\t\"%d\"\n"), -2345);
1706 wxPrintf(wxT("octal negative:\t\"%o\"\n"), -2345);
1707 wxPrintf(wxT("hex negative:\t\"%x\"\n"), -2345);
1708 wxPrintf(wxT("long decimal number:\t\"%ld\"\n"), -123456L);
1709 wxPrintf(wxT("long octal negative:\t\"%lo\"\n"), -2345L);
1710 wxPrintf(wxT("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
1711 wxPrintf(wxT("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
1712 test_format
= wxT("left-adjusted ZLDN:\t\"%-010ld\"\n");
1713 wxPrintf(test_format
.c_str(), -123456);
1714 wxPrintf(wxT("space-padded LDN:\t\"%10ld\"\n"), -123456L);
1715 wxPrintf(wxT("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
1717 test_format
= wxT("zero-padded string:\t\"%010s\"\n");
1718 wxPrintf(test_format
.c_str(), shortstr
);
1719 test_format
= wxT("left-adjusted Z string:\t\"%-010s\"\n");
1720 wxPrintf(test_format
.c_str(), shortstr
);
1721 wxPrintf(wxT("space-padded string:\t\"%10s\"\n"), shortstr
);
1722 wxPrintf(wxT("left-adjusted S string:\t\"%-10s\"\n"), shortstr
);
1723 wxPrintf(wxT("null string:\t\"%s\"\n"), PointerNull
);
1724 wxPrintf(wxT("limited string:\t\"%.22s\"\n"), longstr
);
1726 wxPrintf(wxT("e-style >= 1:\t\"%e\"\n"), 12.34);
1727 wxPrintf(wxT("e-style >= .1:\t\"%e\"\n"), 0.1234);
1728 wxPrintf(wxT("e-style < .1:\t\"%e\"\n"), 0.001234);
1729 wxPrintf(wxT("e-style big:\t\"%.60e\"\n"), 1e20
);
1730 wxPrintf(wxT("e-style == .1:\t\"%e\"\n"), 0.1);
1731 wxPrintf(wxT("f-style >= 1:\t\"%f\"\n"), 12.34);
1732 wxPrintf(wxT("f-style >= .1:\t\"%f\"\n"), 0.1234);
1733 wxPrintf(wxT("f-style < .1:\t\"%f\"\n"), 0.001234);
1734 wxPrintf(wxT("g-style >= 1:\t\"%g\"\n"), 12.34);
1735 wxPrintf(wxT("g-style >= .1:\t\"%g\"\n"), 0.1234);
1736 wxPrintf(wxT("g-style < .1:\t\"%g\"\n"), 0.001234);
1737 wxPrintf(wxT("g-style big:\t\"%.60g\"\n"), 1e20
);
1739 wxPrintf (wxT(" %6.5f\n"), .099999999860301614);
1740 wxPrintf (wxT(" %6.5f\n"), .1);
1741 wxPrintf (wxT("x%5.4fx\n"), .5);
1743 wxPrintf (wxT("%#03x\n"), 1);
1745 //wxPrintf (wxT("something really insane: %.10000f\n"), 1.0);
1751 while (niter
-- != 0)
1752 wxPrintf (wxT("%.17e\n"), d
/ 2);
1757 // Open Watcom cause compiler error here
1758 // Error! E173: col(24) floating-point constant too small to represent
1759 wxPrintf (wxT("%15.5e\n"), 4.9406564584124654e-324);
1762 #define FORMAT wxT("|%12.4f|%12.4e|%12.4g|\n")
1763 wxPrintf (FORMAT
, 0.0, 0.0, 0.0);
1764 wxPrintf (FORMAT
, 1.0, 1.0, 1.0);
1765 wxPrintf (FORMAT
, -1.0, -1.0, -1.0);
1766 wxPrintf (FORMAT
, 100.0, 100.0, 100.0);
1767 wxPrintf (FORMAT
, 1000.0, 1000.0, 1000.0);
1768 wxPrintf (FORMAT
, 10000.0, 10000.0, 10000.0);
1769 wxPrintf (FORMAT
, 12345.0, 12345.0, 12345.0);
1770 wxPrintf (FORMAT
, 100000.0, 100000.0, 100000.0);
1771 wxPrintf (FORMAT
, 123456.0, 123456.0, 123456.0);
1776 int rc
= wxSnprintf (buf
, WXSIZEOF(buf
), wxT("%30s"), wxT("foo"));
1778 wxPrintf(wxT("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1779 rc
, WXSIZEOF(buf
), buf
);
1782 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1783 wxSnprintf(buf2
, WXSIZEOFbuf2
), "%.999999u", 10));
1789 wxPrintf (wxT("%e should be 1.234568e+06\n"), 1234567.8);
1790 wxPrintf (wxT("%f should be 1234567.800000\n"), 1234567.8);
1791 wxPrintf (wxT("%g should be 1.23457e+06\n"), 1234567.8);
1792 wxPrintf (wxT("%g should be 123.456\n"), 123.456);
1793 wxPrintf (wxT("%g should be 1e+06\n"), 1000000.0);
1794 wxPrintf (wxT("%g should be 10\n"), 10.0);
1795 wxPrintf (wxT("%g should be 0.02\n"), 0.02);
1799 wxPrintf(wxT("%.17f\n"),(1.0/x
/10.0+1.0)*x
-x
);
1805 wxSprintf(buf
,wxT("%*s%*s%*s"),-1,wxT("one"),-20,wxT("two"),-30,wxT("three"));
1807 result
|= wxStrcmp (buf
,
1808 wxT("onetwo three "));
1810 wxPuts (result
!= 0 ? wxT("Test failed!") : wxT("Test ok."));
1817 wxSprintf(buf
, "%07" wxLongLongFmtSpec
"o", wxLL(040000000000));
1819 // for some reason below line fails under Borland
1820 wxPrintf (wxT("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf
);
1823 if (wxStrcmp (buf
, wxT("40000000000")) != 0)
1826 wxPuts (wxT("\tFAILED"));
1828 wxUnusedVar(result
);
1829 wxPuts (wxEmptyString
);
1831 #endif // wxLongLong_t
1833 wxPrintf (wxT("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX
+ 2, UCHAR_MAX
+ 2);
1834 wxPrintf (wxT("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX
+ 2, USHRT_MAX
+ 2);
1836 wxPuts (wxT("--- Should be no further output. ---"));
1845 memset (bytes
, '\xff', sizeof bytes
);
1846 wxSprintf (buf
, wxT("foo%hhn\n"), &bytes
[3]);
1847 if (bytes
[0] != '\xff' || bytes
[1] != '\xff' || bytes
[2] != '\xff'
1848 || bytes
[4] != '\xff' || bytes
[5] != '\xff' || bytes
[6] != '\xff')
1850 wxPuts (wxT("%hhn overwrite more bytes"));
1855 wxPuts (wxT("%hhn wrote incorrect value"));
1867 wxSprintf (buf
, wxT("%5.s"), wxT("xyz"));
1868 if (wxStrcmp (buf
, wxT(" ")) != 0)
1869 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" "));
1870 wxSprintf (buf
, wxT("%5.f"), 33.3);
1871 if (wxStrcmp (buf
, wxT(" 33")) != 0)
1872 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 33"));
1873 wxSprintf (buf
, wxT("%8.e"), 33.3e7
);
1874 if (wxStrcmp (buf
, wxT(" 3e+08")) != 0)
1875 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3e+08"));
1876 wxSprintf (buf
, wxT("%8.E"), 33.3e7
);
1877 if (wxStrcmp (buf
, wxT(" 3E+08")) != 0)
1878 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3E+08"));
1879 wxSprintf (buf
, wxT("%.g"), 33.3);
1880 if (wxStrcmp (buf
, wxT("3e+01")) != 0)
1881 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3e+01"));
1882 wxSprintf (buf
, wxT("%.G"), 33.3);
1883 if (wxStrcmp (buf
, wxT("3E+01")) != 0)
1884 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3E+01"));
1892 wxString test_format
;
1895 wxSprintf (buf
, wxT("%.*g"), prec
, 3.3);
1896 if (wxStrcmp (buf
, wxT("3")) != 0)
1897 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
1899 wxSprintf (buf
, wxT("%.*G"), prec
, 3.3);
1900 if (wxStrcmp (buf
, wxT("3")) != 0)
1901 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT("3"));
1903 wxSprintf (buf
, wxT("%7.*G"), prec
, 3.33);
1904 if (wxStrcmp (buf
, wxT(" 3")) != 0)
1905 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 3"));
1907 test_format
= wxT("%04.*o");
1908 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1909 if (wxStrcmp (buf
, wxT(" 041")) != 0)
1910 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 041"));
1912 test_format
= wxT("%09.*u");
1913 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1914 if (wxStrcmp (buf
, wxT(" 0000033")) != 0)
1915 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 0000033"));
1917 test_format
= wxT("%04.*x");
1918 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1919 if (wxStrcmp (buf
, wxT(" 021")) != 0)
1920 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
1922 test_format
= wxT("%04.*X");
1923 wxSprintf (buf
, test_format
.c_str(), prec
, 33);
1924 if (wxStrcmp (buf
, wxT(" 021")) != 0)
1925 wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf
, wxT(" 021"));
1928 #endif // TEST_PRINTF
1930 // ----------------------------------------------------------------------------
1931 // registry and related stuff
1932 // ----------------------------------------------------------------------------
1934 // this is for MSW only
1937 #undef TEST_REGISTRY
1942 #include "wx/confbase.h"
1943 #include "wx/msw/regconf.h"
1946 static void TestRegConfWrite()
1948 wxConfig
*config
= new wxConfig(wxT("myapp"));
1949 config
->SetPath(wxT("/group1"));
1950 config
->Write(wxT("entry1"), wxT("foo"));
1951 config
->SetPath(wxT("/group2"));
1952 config
->Write(wxT("entry1"), wxT("bar"));
1956 static void TestRegConfRead()
1958 wxRegConfig
*config
= new wxRegConfig(wxT("myapp"));
1962 config
->SetPath(wxT("/"));
1963 wxPuts(wxT("Enumerating / subgroups:"));
1964 bool bCont
= config
->GetFirstGroup(str
, dummy
);
1968 bCont
= config
->GetNextGroup(str
, dummy
);
1972 #endif // TEST_REGCONF
1974 #ifdef TEST_REGISTRY
1976 #include "wx/msw/registry.h"
1978 // I chose this one because I liked its name, but it probably only exists under
1980 static const wxChar
*TESTKEY
=
1981 wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
1983 static void TestRegistryRead()
1985 wxPuts(wxT("*** testing registry reading ***"));
1987 wxRegKey
key(TESTKEY
);
1988 wxPrintf(wxT("The test key name is '%s'.\n"), key
.GetName().c_str());
1991 wxPuts(wxT("ERROR: test key can't be opened, aborting test."));
1996 size_t nSubKeys
, nValues
;
1997 if ( key
.GetKeyInfo(&nSubKeys
, NULL
, &nValues
, NULL
) )
1999 wxPrintf(wxT("It has %u subkeys and %u values.\n"), nSubKeys
, nValues
);
2002 wxPrintf(wxT("Enumerating values:\n"));
2006 bool cont
= key
.GetFirstValue(value
, dummy
);
2009 wxPrintf(wxT("Value '%s': type "), value
.c_str());
2010 switch ( key
.GetValueType(value
) )
2012 case wxRegKey::Type_None
: wxPrintf(wxT("ERROR (none)")); break;
2013 case wxRegKey::Type_String
: wxPrintf(wxT("SZ")); break;
2014 case wxRegKey::Type_Expand_String
: wxPrintf(wxT("EXPAND_SZ")); break;
2015 case wxRegKey::Type_Binary
: wxPrintf(wxT("BINARY")); break;
2016 case wxRegKey::Type_Dword
: wxPrintf(wxT("DWORD")); break;
2017 case wxRegKey::Type_Multi_String
: wxPrintf(wxT("MULTI_SZ")); break;
2018 default: wxPrintf(wxT("other (unknown)")); break;
2021 wxPrintf(wxT(", value = "));
2022 if ( key
.IsNumericValue(value
) )
2025 key
.QueryValue(value
, &val
);
2026 wxPrintf(wxT("%ld"), val
);
2031 key
.QueryValue(value
, val
);
2032 wxPrintf(wxT("'%s'"), val
.c_str());
2034 key
.QueryRawValue(value
, val
);
2035 wxPrintf(wxT(" (raw value '%s')"), val
.c_str());
2040 cont
= key
.GetNextValue(value
, dummy
);
2044 static void TestRegistryAssociation()
2047 The second call to deleteself genertaes an error message, with a
2048 messagebox saying .flo is crucial to system operation, while the .ddf
2049 call also fails, but with no error message
2054 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2056 key
= wxT("ddxf_auto_file") ;
2057 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2059 key
= wxT("ddxf_auto_file") ;
2060 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2062 key
= wxT("program,0") ;
2063 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2065 key
= wxT("program \"%1\"") ;
2067 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2069 key
.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2071 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2073 key
.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2077 #endif // TEST_REGISTRY
2079 // ----------------------------------------------------------------------------
2081 // ----------------------------------------------------------------------------
2085 #include "wx/protocol/ftp.h"
2086 #include "wx/protocol/log.h"
2088 #define FTP_ANONYMOUS
2092 #ifdef FTP_ANONYMOUS
2093 static const wxChar
*hostname
= wxT("ftp.wxwidgets.org");
2094 static const wxChar
*directory
= wxT("/pub");
2095 static const wxChar
*filename
= wxT("welcome.msg");
2097 static const wxChar
*hostname
= "localhost";
2098 static const wxChar
*directory
= wxT("/etc");
2099 static const wxChar
*filename
= wxT("issue");
2102 static bool TestFtpConnect()
2104 wxPuts(wxT("*** Testing FTP connect ***"));
2106 #ifdef FTP_ANONYMOUS
2107 wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname
);
2108 #else // !FTP_ANONYMOUS
2110 wxFgets(user
, WXSIZEOF(user
), stdin
);
2111 user
[wxStrlen(user
) - 1] = '\0'; // chop off '\n'
2114 wxChar password
[256];
2115 wxPrintf(wxT("Password for %s: "), password
);
2116 wxFgets(password
, WXSIZEOF(password
), stdin
);
2117 password
[wxStrlen(password
) - 1] = '\0'; // chop off '\n'
2118 ftp
->SetPassword(password
);
2120 wxPrintf(wxT("--- Attempting to connect to %s:21 as %s...\n"), hostname
, user
);
2121 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2123 if ( !ftp
->Connect(hostname
) )
2125 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname
);
2131 wxPrintf(wxT("--- Connected to %s, current directory is '%s'\n"),
2132 hostname
, ftp
->Pwd().c_str());
2139 #if TEST_INTERACTIVE
2140 static void TestFtpInteractive()
2142 wxPuts(wxT("\n*** Interactive wxFTP test ***"));
2148 wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
2149 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2152 // kill the last '\n'
2153 buf
[wxStrlen(buf
) - 1] = 0;
2155 // special handling of LIST and NLST as they require data connection
2156 wxString
start(buf
, 4);
2158 if ( start
== wxT("LIST") || start
== wxT("NLST") )
2161 if ( wxStrlen(buf
) > 4 )
2164 wxArrayString files
;
2165 if ( !ftp
->GetList(files
, wildcard
, start
== wxT("LIST")) )
2167 wxPrintf(wxT("ERROR: failed to get %s of files\n"), start
.c_str());
2171 wxPrintf(wxT("--- %s of '%s' under '%s':\n"),
2172 start
.c_str(), wildcard
.c_str(), ftp
->Pwd().c_str());
2173 size_t count
= files
.GetCount();
2174 for ( size_t n
= 0; n
< count
; n
++ )
2176 wxPrintf(wxT("\t%s\n"), files
[n
].c_str());
2178 wxPuts(wxT("--- End of the file list"));
2181 else if ( start
== wxT("QUIT") )
2183 break; // get out of here!
2187 wxChar ch
= ftp
->SendCommand(buf
);
2188 wxPrintf(wxT("Command %s"), ch
? wxT("succeeded") : wxT("failed"));
2191 wxPrintf(wxT(" (return code %c)"), ch
);
2194 wxPrintf(wxT(", server reply:\n%s\n\n"), ftp
->GetLastResult().c_str());
2200 #endif // TEST_INTERACTIVE
2203 // ----------------------------------------------------------------------------
2205 // ----------------------------------------------------------------------------
2207 #ifdef TEST_STACKWALKER
2209 #if wxUSE_STACKWALKER
2211 #include "wx/stackwalk.h"
2213 class StackDump
: public wxStackWalker
2216 StackDump(const char *argv0
)
2217 : wxStackWalker(argv0
)
2221 virtual void Walk(size_t skip
= 1, size_t maxdepth
= wxSTACKWALKER_MAX_DEPTH
)
2223 wxPuts(wxT("Stack dump:"));
2225 wxStackWalker::Walk(skip
, maxdepth
);
2229 virtual void OnStackFrame(const wxStackFrame
& frame
)
2231 printf("[%2d] ", (int) frame
.GetLevel());
2233 wxString name
= frame
.GetName();
2234 if ( !name
.empty() )
2236 printf("%-20.40s", (const char*)name
.mb_str());
2240 printf("0x%08lx", (unsigned long)frame
.GetAddress());
2243 if ( frame
.HasSourceLocation() )
2246 (const char*)frame
.GetFileName().mb_str(),
2247 (int)frame
.GetLine());
2253 for ( size_t n
= 0; frame
.GetParam(n
, &type
, &name
, &val
); n
++ )
2255 printf("\t%s %s = %s\n", (const char*)type
.mb_str(),
2256 (const char*)name
.mb_str(),
2257 (const char*)val
.mb_str());
2262 static void TestStackWalk(const char *argv0
)
2264 wxPuts(wxT("*** Testing wxStackWalker ***"));
2266 StackDump
dump(argv0
);
2272 #endif // wxUSE_STACKWALKER
2274 #endif // TEST_STACKWALKER
2276 // ----------------------------------------------------------------------------
2278 // ----------------------------------------------------------------------------
2280 #ifdef TEST_STDPATHS
2282 #include "wx/stdpaths.h"
2283 #include "wx/wxchar.h" // wxPrintf
2285 static void TestStandardPaths()
2287 wxPuts(wxT("*** Testing wxStandardPaths ***"));
2289 wxTheApp
->SetAppName(wxT("console"));
2291 wxStandardPathsBase
& stdp
= wxStandardPaths::Get();
2292 wxPrintf(wxT("Config dir (sys):\t%s\n"), stdp
.GetConfigDir().c_str());
2293 wxPrintf(wxT("Config dir (user):\t%s\n"), stdp
.GetUserConfigDir().c_str());
2294 wxPrintf(wxT("Data dir (sys):\t\t%s\n"), stdp
.GetDataDir().c_str());
2295 wxPrintf(wxT("Data dir (sys local):\t%s\n"), stdp
.GetLocalDataDir().c_str());
2296 wxPrintf(wxT("Data dir (user):\t%s\n"), stdp
.GetUserDataDir().c_str());
2297 wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp
.GetUserLocalDataDir().c_str());
2298 wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp
.GetDocumentsDir().c_str());
2299 wxPrintf(wxT("Executable path:\t%s\n"), stdp
.GetExecutablePath().c_str());
2300 wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp
.GetPluginsDir().c_str());
2301 wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp
.GetResourcesDir().c_str());
2302 wxPrintf(wxT("Localized res. dir:\t%s\n"),
2303 stdp
.GetLocalizedResourcesDir(wxT("fr")).c_str());
2304 wxPrintf(wxT("Message catalogs dir:\t%s\n"),
2305 stdp
.GetLocalizedResourcesDir
2308 wxStandardPaths::ResourceCat_Messages
2314 #endif // TEST_STDPATHS
2316 // ----------------------------------------------------------------------------
2318 // ----------------------------------------------------------------------------
2320 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
2326 #include "wx/volume.h"
2328 static const wxChar
*volumeKinds
[] =
2334 wxT("network volume"),
2335 wxT("other volume"),
2338 static void TestFSVolume()
2340 wxPuts(wxT("*** Testing wxFSVolume class ***"));
2342 wxArrayString volumes
= wxFSVolume::GetVolumes();
2343 size_t count
= volumes
.GetCount();
2347 wxPuts(wxT("ERROR: no mounted volumes?"));
2351 wxPrintf(wxT("%u mounted volumes found:\n"), count
);
2353 for ( size_t n
= 0; n
< count
; n
++ )
2355 wxFSVolume
vol(volumes
[n
]);
2358 wxPuts(wxT("ERROR: couldn't create volume"));
2362 wxPrintf(wxT("%u: %s (%s), %s, %s, %s\n"),
2364 vol
.GetDisplayName().c_str(),
2365 vol
.GetName().c_str(),
2366 volumeKinds
[vol
.GetKind()],
2367 vol
.IsWritable() ? wxT("rw") : wxT("ro"),
2368 vol
.GetFlags() & wxFS_VOL_REMOVABLE
? wxT("removable")
2375 #endif // TEST_VOLUME
2377 // ----------------------------------------------------------------------------
2379 // ----------------------------------------------------------------------------
2381 #ifdef TEST_DATETIME
2383 #include "wx/math.h"
2384 #include "wx/datetime.h"
2386 #if TEST_INTERACTIVE
2388 static void TestDateTimeInteractive()
2390 wxPuts(wxT("\n*** interactive wxDateTime tests ***"));
2396 wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
2397 if ( !wxFgets(buf
, WXSIZEOF(buf
), stdin
) )
2400 // kill the last '\n'
2401 buf
[wxStrlen(buf
) - 1] = 0;
2403 if ( wxString(buf
).CmpNoCase("quit") == 0 )
2407 const wxChar
*p
= dt
.ParseDate(buf
);
2410 wxPrintf(wxT("ERROR: failed to parse the date '%s'.\n"), buf
);
2416 wxPrintf(wxT("WARNING: parsed only first %u characters.\n"), p
- buf
);
2419 wxPrintf(wxT("%s: day %u, week of month %u/%u, week of year %u\n"),
2420 dt
.Format(wxT("%b %d, %Y")).c_str(),
2422 dt
.GetWeekOfMonth(wxDateTime::Monday_First
),
2423 dt
.GetWeekOfMonth(wxDateTime::Sunday_First
),
2424 dt
.GetWeekOfYear(wxDateTime::Monday_First
));
2430 #endif // TEST_INTERACTIVE
2431 #endif // TEST_DATETIME
2433 // ----------------------------------------------------------------------------
2435 // ----------------------------------------------------------------------------
2437 #ifdef TEST_SNGLINST
2439 #include "wx/snglinst.h"
2441 static bool TestSingleIstance()
2443 wxPuts(wxT("\n*** Testing wxSingleInstanceChecker ***"));
2445 wxSingleInstanceChecker checker
;
2446 if ( checker
.Create(wxT(".wxconsole.lock")) )
2448 if ( checker
.IsAnotherRunning() )
2450 wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
2455 // wait some time to give time to launch another instance
2456 wxPuts(wxT("If you try to run another instance of this program now, it won't start."));
2457 wxPrintf(wxT("Press \"Enter\" to exit wxSingleInstanceChecker test and proceed..."));
2460 else // failed to create
2462 wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
2469 #endif // TEST_SNGLINST
2472 // ----------------------------------------------------------------------------
2474 // ----------------------------------------------------------------------------
2476 int main(int argc
, char **argv
)
2479 wxChar
**wxArgv
= new wxChar
*[argc
+ 1];
2484 for (n
= 0; n
< argc
; n
++ )
2486 wxMB2WXbuf warg
= wxConvertMB2WX(argv
[n
]);
2487 wxArgv
[n
] = wxStrdup(warg
);
2492 #else // !wxUSE_UNICODE
2494 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
2496 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE
, "program");
2498 wxInitializer initializer
;
2501 fprintf(stderr
, "Failed to initialize the wxWidgets library, aborting.");
2506 #ifdef TEST_SNGLINST
2507 if (!TestSingleIstance())
2509 #endif // TEST_SNGLINST
2521 TestDllListLoaded();
2522 #endif // TEST_DYNLIB
2526 #endif // TEST_ENVIRON
2528 #ifdef TEST_FILECONF
2530 #endif // TEST_FILECONF
2534 #endif // TEST_LOCALE
2537 wxPuts(wxT("*** Testing wxLog ***"));
2540 for ( size_t n
= 0; n
< 8000; n
++ )
2542 s
<< (wxChar
)(wxT('A') + (n
% 26));
2545 wxLogWarning(wxT("The length of the string is %lu"),
2546 (unsigned long)s
.length());
2549 msg
.Printf(wxT("A very very long message: '%s', the end!\n"), s
.c_str());
2551 // this one shouldn't be truncated
2554 // but this one will because log functions use fixed size buffer
2555 // (note that it doesn't need '\n' at the end neither - will be added
2557 wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s
.c_str());
2567 #ifdef TEST_FILENAME
2570 TestFileNameDirManip();
2571 TestFileNameComparison();
2572 TestFileNameOperations();
2573 #endif // TEST_FILENAME
2575 #ifdef TEST_FILETIME
2580 #endif // TEST_FILETIME
2583 wxLog::AddTraceMask(FTP_TRACE_MASK
);
2585 // wxFTP cannot be a static variable as its ctor needs to access
2586 // wxWidgets internals after it has been initialized
2588 ftp
->SetLog(new wxProtocolLog(FTP_TRACE_MASK
));
2589 if ( TestFtpConnect() )
2590 TestFtpInteractive();
2591 //else: connecting to the FTP server failed
2597 //wxLog::AddTraceMask(wxT("mime"));
2601 TestMimeAssociate();
2606 #ifdef TEST_INFO_FUNCTIONS
2611 #if TEST_INTERACTIVE
2614 #endif // TEST_INFO_FUNCTIONS
2616 #ifdef TEST_PATHLIST
2618 #endif // TEST_PATHLIST
2622 #endif // TEST_PRINTF
2629 #endif // TEST_REGCONF
2631 #if defined TEST_REGEX && TEST_INTERACTIVE
2632 TestRegExInteractive();
2633 #endif // defined TEST_REGEX && TEST_INTERACTIVE
2635 #ifdef TEST_REGISTRY
2637 TestRegistryAssociation();
2638 #endif // TEST_REGISTRY
2640 #ifdef TEST_DATETIME
2641 #if TEST_INTERACTIVE
2642 TestDateTimeInteractive();
2644 #endif // TEST_DATETIME
2646 #ifdef TEST_STACKWALKER
2647 #if wxUSE_STACKWALKER
2648 TestStackWalk(argv
[0]);
2650 #endif // TEST_STACKWALKER
2652 #ifdef TEST_STDPATHS
2653 TestStandardPaths();
2657 wxPuts(wxT("Sleeping for 3 seconds... z-z-z-z-z..."));
2659 #endif // TEST_USLEEP
2663 #endif // TEST_VOLUME
2667 for ( int n
= 0; n
< argc
; n
++ )
2672 #endif // wxUSE_UNICODE