]> git.saurik.com Git - wxWidgets.git/blob - samples/console/console.cpp
Move some wxPrintf() tests (taken from glibc) to VsnprintfTestCase. Other tests are...
[wxWidgets.git] / samples / console / console.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/console/console.cpp
3 // Purpose: A sample console (as opposed to GUI) program using wxWidgets
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 04.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
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:
18
19 /*
20 int main(int argc, char **argv)
21 {
22 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
23
24 wxInitializer initializer;
25 if ( !initializer )
26 {
27 fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
28 return -1;
29 }
30
31 static const wxCmdLineEntryDesc cmdLineDesc[] =
32 {
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...
36
37 { wxCMD_LINE_NONE }
38 };
39
40 wxCmdLineParser parser(cmdLineDesc, argc, wxArgv);
41 switch ( parser.Parse() )
42 {
43 case -1:
44 wxLogMessage(wxT("Help was given, terminating."));
45 break;
46
47 case 0:
48 // everything is ok; proceed
49 break;
50
51 default:
52 wxLogMessage(wxT("Syntax error detected, aborting."));
53 break;
54 }
55
56 // do something useful here
57
58 return 0;
59 }
60 */
61
62
63 // ============================================================================
64 // declarations
65 // ============================================================================
66
67 // ----------------------------------------------------------------------------
68 // headers
69 // ----------------------------------------------------------------------------
70
71 #include "wx/defs.h"
72
73 #include <stdio.h>
74
75 #include "wx/string.h"
76 #include "wx/file.h"
77 #include "wx/filename.h"
78 #include "wx/app.h"
79 #include "wx/log.h"
80 #include "wx/apptrait.h"
81 #include "wx/platinfo.h"
82 #include "wx/wxchar.h"
83
84 // without this pragma, the stupid compiler precompiles #defines below so that
85 // changing them doesn't "take place" later!
86 #ifdef __VISUALC__
87 #pragma hdrstop
88 #endif
89
90 // ----------------------------------------------------------------------------
91 // conditional compilation
92 // ----------------------------------------------------------------------------
93
94 /*
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.
100 */
101
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.
104 #define TEST_ALL 0
105
106
107 #if TEST_ALL
108 #define TEST_DATETIME
109 #define TEST_DIR
110 #define TEST_DYNLIB
111 #define TEST_ENVIRON
112 #define TEST_FILE
113 #define TEST_FILECONF
114 #define TEST_FILENAME
115 #define TEST_FILETIME
116 #define TEST_INFO_FUNCTIONS
117 #define TEST_LOCALE
118 #define TEST_LOG
119 #define TEST_MIME
120 #define TEST_MODULE
121 #define TEST_PATHLIST
122 #else // #if TEST_ALL
123 #define TEST_DATETIME
124 #define TEST_VOLUME
125 #define TEST_STDPATHS
126 #define TEST_STACKWALKER
127 #define TEST_FTP
128 #define TEST_SNGLINST
129 #define TEST_REGEX
130 #endif
131
132 // some tests are interactive, define this to run them
133 #ifdef TEST_INTERACTIVE
134 #undef TEST_INTERACTIVE
135
136 #define TEST_INTERACTIVE 1
137 #else
138 #define TEST_INTERACTIVE 1
139 #endif
140
141 // ============================================================================
142 // implementation
143 // ============================================================================
144
145 // ----------------------------------------------------------------------------
146 // wxDir
147 // ----------------------------------------------------------------------------
148
149 #ifdef TEST_DIR
150
151 #include "wx/dir.h"
152
153 #ifdef __UNIX__
154 static const wxChar *ROOTDIR = wxT("/");
155 static const wxChar *TESTDIR = wxT("/usr/local/share");
156 #elif defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
157 static const wxChar *ROOTDIR = wxT("c:\\");
158 static const wxChar *TESTDIR = wxT("d:\\");
159 #else
160 #error "don't know where the root directory is"
161 #endif
162
163 static void TestDirEnumHelper(wxDir& dir,
164 int flags = wxDIR_DEFAULT,
165 const wxString& filespec = wxEmptyString)
166 {
167 wxString filename;
168
169 if ( !dir.IsOpened() )
170 return;
171
172 bool cont = dir.GetFirst(&filename, filespec, flags);
173 while ( cont )
174 {
175 wxPrintf(wxT("\t%s\n"), filename.c_str());
176
177 cont = dir.GetNext(&filename);
178 }
179
180 wxPuts(wxEmptyString);
181 }
182
183 #if TEST_ALL
184
185 static void TestDirEnum()
186 {
187 wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
188
189 wxString cwd = wxGetCwd();
190 if ( !wxDir::Exists(cwd) )
191 {
192 wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd.c_str());
193 return;
194 }
195
196 wxDir dir(cwd);
197 if ( !dir.IsOpened() )
198 {
199 wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd.c_str());
200 return;
201 }
202
203 wxPuts(wxT("Enumerating everything in current directory:"));
204 TestDirEnumHelper(dir);
205
206 wxPuts(wxT("Enumerating really everything in current directory:"));
207 TestDirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT);
208
209 wxPuts(wxT("Enumerating object files in current directory:"));
210 TestDirEnumHelper(dir, wxDIR_DEFAULT, wxT("*.o*"));
211
212 wxPuts(wxT("Enumerating directories in current directory:"));
213 TestDirEnumHelper(dir, wxDIR_DIRS);
214
215 wxPuts(wxT("Enumerating files in current directory:"));
216 TestDirEnumHelper(dir, wxDIR_FILES);
217
218 wxPuts(wxT("Enumerating files including hidden in current directory:"));
219 TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
220
221 dir.Open(ROOTDIR);
222
223 wxPuts(wxT("Enumerating everything in root directory:"));
224 TestDirEnumHelper(dir, wxDIR_DEFAULT);
225
226 wxPuts(wxT("Enumerating directories in root directory:"));
227 TestDirEnumHelper(dir, wxDIR_DIRS);
228
229 wxPuts(wxT("Enumerating files in root directory:"));
230 TestDirEnumHelper(dir, wxDIR_FILES);
231
232 wxPuts(wxT("Enumerating files including hidden in root directory:"));
233 TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
234
235 wxPuts(wxT("Enumerating files in non existing directory:"));
236 wxDir dirNo(wxT("nosuchdir"));
237 TestDirEnumHelper(dirNo);
238 }
239
240 #endif // TEST_ALL
241
242 class DirPrintTraverser : public wxDirTraverser
243 {
244 public:
245 virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
246 {
247 return wxDIR_CONTINUE;
248 }
249
250 virtual wxDirTraverseResult OnDir(const wxString& dirname)
251 {
252 wxString path, name, ext;
253 wxFileName::SplitPath(dirname, &path, &name, &ext);
254
255 if ( !ext.empty() )
256 name << wxT('.') << ext;
257
258 wxString indent;
259 for ( const wxChar *p = path.c_str(); *p; p++ )
260 {
261 if ( wxIsPathSeparator(*p) )
262 indent += wxT(" ");
263 }
264
265 wxPrintf(wxT("%s%s\n"), indent.c_str(), name.c_str());
266
267 return wxDIR_CONTINUE;
268 }
269 };
270
271 static void TestDirTraverse()
272 {
273 wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
274
275 // enum all files
276 wxArrayString files;
277 size_t n = wxDir::GetAllFiles(TESTDIR, &files);
278 wxPrintf(wxT("There are %u files under '%s'\n"), n, TESTDIR);
279 if ( n > 1 )
280 {
281 wxPrintf(wxT("First one is '%s'\n"), files[0u].c_str());
282 wxPrintf(wxT(" last one is '%s'\n"), files[n - 1].c_str());
283 }
284
285 // enum again with custom traverser
286 wxPuts(wxT("Now enumerating directories:"));
287 wxDir dir(TESTDIR);
288 DirPrintTraverser traverser;
289 dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN);
290 }
291
292 #if TEST_ALL
293
294 static void TestDirExists()
295 {
296 wxPuts(wxT("*** Testing wxDir::Exists() ***"));
297
298 static const wxChar *dirnames[] =
299 {
300 wxT("."),
301 #if defined(__WXMSW__)
302 wxT("c:"),
303 wxT("c:\\"),
304 wxT("\\\\share\\file"),
305 wxT("c:\\dos"),
306 wxT("c:\\dos\\"),
307 wxT("c:\\dos\\\\"),
308 wxT("c:\\autoexec.bat"),
309 #elif defined(__UNIX__)
310 wxT("/"),
311 wxT("//"),
312 wxT("/usr/bin"),
313 wxT("/usr//bin"),
314 wxT("/usr///bin"),
315 #endif
316 };
317
318 for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
319 {
320 wxPrintf(wxT("%-40s: %s\n"),
321 dirnames[n],
322 wxDir::Exists(dirnames[n]) ? wxT("exists")
323 : wxT("doesn't exist"));
324 }
325 }
326
327 #endif // TEST_ALL
328
329 #endif // TEST_DIR
330
331 // ----------------------------------------------------------------------------
332 // wxDllLoader
333 // ----------------------------------------------------------------------------
334
335 #ifdef TEST_DYNLIB
336
337 #include "wx/dynlib.h"
338
339 static void TestDllLoad()
340 {
341 #if defined(__WXMSW__)
342 static const wxChar *LIB_NAME = wxT("kernel32.dll");
343 static const wxChar *FUNC_NAME = wxT("lstrlenA");
344 #elif defined(__UNIX__)
345 // weird: using just libc.so does *not* work!
346 static const wxChar *LIB_NAME = wxT("/lib/libc.so.6");
347 static const wxChar *FUNC_NAME = wxT("strlen");
348 #else
349 #error "don't know how to test wxDllLoader on this platform"
350 #endif
351
352 wxPuts(wxT("*** testing basic wxDynamicLibrary functions ***\n"));
353
354 wxDynamicLibrary lib(LIB_NAME);
355 if ( !lib.IsLoaded() )
356 {
357 wxPrintf(wxT("ERROR: failed to load '%s'.\n"), LIB_NAME);
358 }
359 else
360 {
361 typedef int (wxSTDCALL *wxStrlenType)(const char *);
362 wxStrlenType pfnStrlen = (wxStrlenType)lib.GetSymbol(FUNC_NAME);
363 if ( !pfnStrlen )
364 {
365 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
366 FUNC_NAME, LIB_NAME);
367 }
368 else
369 {
370 wxPrintf(wxT("Calling %s dynamically loaded from %s "),
371 FUNC_NAME, LIB_NAME);
372
373 if ( pfnStrlen("foo") != 3 )
374 {
375 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
376 }
377 else
378 {
379 wxPuts(wxT("... ok"));
380 }
381 }
382
383 #ifdef __WXMSW__
384 static const wxChar *FUNC_NAME_AW = wxT("lstrlen");
385
386 typedef int (wxSTDCALL *wxStrlenTypeAorW)(const wxChar *);
387 wxStrlenTypeAorW
388 pfnStrlenAorW = (wxStrlenTypeAorW)lib.GetSymbolAorW(FUNC_NAME_AW);
389 if ( !pfnStrlenAorW )
390 {
391 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
392 FUNC_NAME_AW, LIB_NAME);
393 }
394 else
395 {
396 if ( pfnStrlenAorW(wxT("foobar")) != 6 )
397 {
398 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
399 }
400 }
401 #endif // __WXMSW__
402 }
403 }
404
405 #if defined(__WXMSW__) || defined(__UNIX__)
406
407 static void TestDllListLoaded()
408 {
409 wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
410
411 puts("\nLoaded modules:");
412 wxDynamicLibraryDetailsArray dlls = wxDynamicLibrary::ListLoaded();
413 const size_t count = dlls.GetCount();
414 for ( size_t n = 0; n < count; ++n )
415 {
416 const wxDynamicLibraryDetails& details = dlls[n];
417 printf("%-45s", (const char *)details.GetPath().mb_str());
418
419 void *addr wxDUMMY_INITIALIZE(NULL);
420 size_t len wxDUMMY_INITIALIZE(0);
421 if ( details.GetAddress(&addr, &len) )
422 {
423 printf(" %08lx:%08lx",
424 (unsigned long)addr, (unsigned long)((char *)addr + len));
425 }
426
427 printf(" %s\n", (const char *)details.GetVersion().mb_str());
428 }
429 }
430
431 #endif
432
433 #endif // TEST_DYNLIB
434
435 // ----------------------------------------------------------------------------
436 // wxGet/SetEnv
437 // ----------------------------------------------------------------------------
438
439 #ifdef TEST_ENVIRON
440
441 #include "wx/utils.h"
442
443 static wxString MyGetEnv(const wxString& var)
444 {
445 wxString val;
446 if ( !wxGetEnv(var, &val) )
447 val = wxT("<empty>");
448 else
449 val = wxString(wxT('\'')) + val + wxT('\'');
450
451 return val;
452 }
453
454 static void TestEnvironment()
455 {
456 const wxChar *var = wxT("wxTestVar");
457
458 wxPuts(wxT("*** testing environment access functions ***"));
459
460 wxPrintf(wxT("Initially getenv(%s) = %s\n"), var, MyGetEnv(var).c_str());
461 wxSetEnv(var, wxT("value for wxTestVar"));
462 wxPrintf(wxT("After wxSetEnv: getenv(%s) = %s\n"), var, MyGetEnv(var).c_str());
463 wxSetEnv(var, wxT("another value"));
464 wxPrintf(wxT("After 2nd wxSetEnv: getenv(%s) = %s\n"), var, MyGetEnv(var).c_str());
465 wxUnsetEnv(var);
466 wxPrintf(wxT("After wxUnsetEnv: getenv(%s) = %s\n"), var, MyGetEnv(var).c_str());
467 wxPrintf(wxT("PATH = %s\n"), MyGetEnv(wxT("PATH")).c_str());
468 }
469
470 #endif // TEST_ENVIRON
471
472 // ----------------------------------------------------------------------------
473 // file
474 // ----------------------------------------------------------------------------
475
476 #ifdef TEST_FILE
477
478 #include "wx/file.h"
479 #include "wx/ffile.h"
480 #include "wx/textfile.h"
481
482 static void TestFileRead()
483 {
484 wxPuts(wxT("*** wxFile read test ***"));
485
486 wxFile file(wxT("testdata.fc"));
487 if ( file.IsOpened() )
488 {
489 wxPrintf(wxT("File length: %lu\n"), file.Length());
490
491 wxPuts(wxT("File dump:\n----------"));
492
493 static const size_t len = 1024;
494 wxChar buf[len];
495 for ( ;; )
496 {
497 size_t nRead = file.Read(buf, len);
498 if ( nRead == (size_t)wxInvalidOffset )
499 {
500 wxPrintf(wxT("Failed to read the file."));
501 break;
502 }
503
504 fwrite(buf, nRead, 1, stdout);
505
506 if ( nRead < len )
507 break;
508 }
509
510 wxPuts(wxT("----------"));
511 }
512 else
513 {
514 wxPrintf(wxT("ERROR: can't open test file.\n"));
515 }
516
517 wxPuts(wxEmptyString);
518 }
519
520 static void TestTextFileRead()
521 {
522 wxPuts(wxT("*** wxTextFile read test ***"));
523
524 wxTextFile file(wxT("testdata.fc"));
525 if ( file.Open() )
526 {
527 wxPrintf(wxT("Number of lines: %u\n"), file.GetLineCount());
528 wxPrintf(wxT("Last line: '%s'\n"), file.GetLastLine().c_str());
529
530 wxString s;
531
532 wxPuts(wxT("\nDumping the entire file:"));
533 for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
534 {
535 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
536 }
537 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
538
539 wxPuts(wxT("\nAnd now backwards:"));
540 for ( s = file.GetLastLine();
541 file.GetCurrentLine() != 0;
542 s = file.GetPrevLine() )
543 {
544 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
545 }
546 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
547 }
548 else
549 {
550 wxPrintf(wxT("ERROR: can't open '%s'\n"), file.GetName());
551 }
552
553 wxPuts(wxEmptyString);
554 }
555
556 static void TestFileCopy()
557 {
558 wxPuts(wxT("*** Testing wxCopyFile ***"));
559
560 static const wxChar *filename1 = wxT("testdata.fc");
561 static const wxChar *filename2 = wxT("test2");
562 if ( !wxCopyFile(filename1, filename2) )
563 {
564 wxPuts(wxT("ERROR: failed to copy file"));
565 }
566 else
567 {
568 wxFFile f1(filename1, wxT("rb")),
569 f2(filename2, wxT("rb"));
570
571 if ( !f1.IsOpened() || !f2.IsOpened() )
572 {
573 wxPuts(wxT("ERROR: failed to open file(s)"));
574 }
575 else
576 {
577 wxString s1, s2;
578 if ( !f1.ReadAll(&s1) || !f2.ReadAll(&s2) )
579 {
580 wxPuts(wxT("ERROR: failed to read file(s)"));
581 }
582 else
583 {
584 if ( (s1.length() != s2.length()) ||
585 (memcmp(s1.c_str(), s2.c_str(), s1.length()) != 0) )
586 {
587 wxPuts(wxT("ERROR: copy error!"));
588 }
589 else
590 {
591 wxPuts(wxT("File was copied ok."));
592 }
593 }
594 }
595 }
596
597 if ( !wxRemoveFile(filename2) )
598 {
599 wxPuts(wxT("ERROR: failed to remove the file"));
600 }
601
602 wxPuts(wxEmptyString);
603 }
604
605 static void TestTempFile()
606 {
607 wxPuts(wxT("*** wxTempFile test ***"));
608
609 wxTempFile tmpFile;
610 if ( tmpFile.Open(wxT("test2")) && tmpFile.Write(wxT("the answer is 42")) )
611 {
612 if ( tmpFile.Commit() )
613 wxPuts(wxT("File committed."));
614 else
615 wxPuts(wxT("ERROR: could't commit temp file."));
616
617 wxRemoveFile(wxT("test2"));
618 }
619
620 wxPuts(wxEmptyString);
621 }
622
623 #endif // TEST_FILE
624
625 // ----------------------------------------------------------------------------
626 // wxFileConfig
627 // ----------------------------------------------------------------------------
628
629 #ifdef TEST_FILECONF
630
631 #include "wx/confbase.h"
632 #include "wx/fileconf.h"
633
634 static const struct FileConfTestData
635 {
636 const wxChar *name; // value name
637 const wxChar *value; // the value from the file
638 } fcTestData[] =
639 {
640 { wxT("value1"), wxT("one") },
641 { wxT("value2"), wxT("two") },
642 { wxT("novalue"), wxT("default") },
643 };
644
645 static void TestFileConfRead()
646 {
647 wxPuts(wxT("*** testing wxFileConfig loading/reading ***"));
648
649 wxFileConfig fileconf(wxT("test"), wxEmptyString,
650 wxT("testdata.fc"), wxEmptyString,
651 wxCONFIG_USE_RELATIVE_PATH);
652
653 // test simple reading
654 wxPuts(wxT("\nReading config file:"));
655 wxString defValue(wxT("default")), value;
656 for ( size_t n = 0; n < WXSIZEOF(fcTestData); n++ )
657 {
658 const FileConfTestData& data = fcTestData[n];
659 value = fileconf.Read(data.name, defValue);
660 wxPrintf(wxT("\t%s = %s "), data.name, value.c_str());
661 if ( value == data.value )
662 {
663 wxPuts(wxT("(ok)"));
664 }
665 else
666 {
667 wxPrintf(wxT("(ERROR: should be %s)\n"), data.value);
668 }
669 }
670
671 // test enumerating the entries
672 wxPuts(wxT("\nEnumerating all root entries:"));
673 long dummy;
674 wxString name;
675 bool cont = fileconf.GetFirstEntry(name, dummy);
676 while ( cont )
677 {
678 wxPrintf(wxT("\t%s = %s\n"),
679 name.c_str(),
680 fileconf.Read(name.c_str(), wxT("ERROR")).c_str());
681
682 cont = fileconf.GetNextEntry(name, dummy);
683 }
684
685 static const wxChar *testEntry = wxT("TestEntry");
686 wxPrintf(wxT("\nTesting deletion of newly created \"Test\" entry: "));
687 fileconf.Write(testEntry, wxT("A value"));
688 fileconf.DeleteEntry(testEntry);
689 wxPrintf(fileconf.HasEntry(testEntry) ? wxT("ERROR\n") : wxT("ok\n"));
690 }
691
692 #endif // TEST_FILECONF
693
694 // ----------------------------------------------------------------------------
695 // wxFileName
696 // ----------------------------------------------------------------------------
697
698 #ifdef TEST_FILENAME
699
700 #include "wx/filename.h"
701
702 #if 0
703 static void DumpFileName(const wxChar *desc, const wxFileName& fn)
704 {
705 wxPuts(desc);
706
707 wxString full = fn.GetFullPath();
708
709 wxString vol, path, name, ext;
710 wxFileName::SplitPath(full, &vol, &path, &name, &ext);
711
712 wxPrintf(wxT("'%s'-> vol '%s', path '%s', name '%s', ext '%s'\n"),
713 full.c_str(), vol.c_str(), path.c_str(), name.c_str(), ext.c_str());
714
715 wxFileName::SplitPath(full, &path, &name, &ext);
716 wxPrintf(wxT("or\t\t-> path '%s', name '%s', ext '%s'\n"),
717 path.c_str(), name.c_str(), ext.c_str());
718
719 wxPrintf(wxT("path is also:\t'%s'\n"), fn.GetPath().c_str());
720 wxPrintf(wxT("with volume: \t'%s'\n"),
721 fn.GetPath(wxPATH_GET_VOLUME).c_str());
722 wxPrintf(wxT("with separator:\t'%s'\n"),
723 fn.GetPath(wxPATH_GET_SEPARATOR).c_str());
724 wxPrintf(wxT("with both: \t'%s'\n"),
725 fn.GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME).c_str());
726
727 wxPuts(wxT("The directories in the path are:"));
728 wxArrayString dirs = fn.GetDirs();
729 size_t count = dirs.GetCount();
730 for ( size_t n = 0; n < count; n++ )
731 {
732 wxPrintf(wxT("\t%u: %s\n"), n, dirs[n].c_str());
733 }
734 }
735 #endif
736
737 static void TestFileNameTemp()
738 {
739 wxPuts(wxT("*** testing wxFileName temp file creation ***"));
740
741 static const wxChar *tmpprefixes[] =
742 {
743 wxT(""),
744 wxT("foo"),
745 wxT(".."),
746 wxT("../bar"),
747 #ifdef __UNIX__
748 wxT("/tmp/foo"),
749 wxT("/tmp/foo/bar"), // this one must be an error
750 #endif // __UNIX__
751 };
752
753 for ( size_t n = 0; n < WXSIZEOF(tmpprefixes); n++ )
754 {
755 wxString path = wxFileName::CreateTempFileName(tmpprefixes[n]);
756 if ( path.empty() )
757 {
758 // "error" is not in upper case because it may be ok
759 wxPrintf(wxT("Prefix '%s'\t-> error\n"), tmpprefixes[n]);
760 }
761 else
762 {
763 wxPrintf(wxT("Prefix '%s'\t-> temp file '%s'\n"),
764 tmpprefixes[n], path.c_str());
765
766 if ( !wxRemoveFile(path) )
767 {
768 wxLogWarning(wxT("Failed to remove temp file '%s'"),
769 path.c_str());
770 }
771 }
772 }
773 }
774
775 static void TestFileNameDirManip()
776 {
777 // TODO: test AppendDir(), RemoveDir(), ...
778 }
779
780 static void TestFileNameComparison()
781 {
782 // TODO!
783 }
784
785 static void TestFileNameOperations()
786 {
787 // TODO!
788 }
789
790 static void TestFileNameCwd()
791 {
792 // TODO!
793 }
794
795 #endif // TEST_FILENAME
796
797 // ----------------------------------------------------------------------------
798 // wxFileName time functions
799 // ----------------------------------------------------------------------------
800
801 #ifdef TEST_FILETIME
802
803 #include "wx/filename.h"
804 #include "wx/datetime.h"
805
806 static void TestFileGetTimes()
807 {
808 wxFileName fn(wxT("testdata.fc"));
809
810 wxDateTime dtAccess, dtMod, dtCreate;
811 if ( !fn.GetTimes(&dtAccess, &dtMod, &dtCreate) )
812 {
813 wxPrintf(wxT("ERROR: GetTimes() failed.\n"));
814 }
815 else
816 {
817 static const wxChar *fmt = wxT("%Y-%b-%d %H:%M:%S");
818
819 wxPrintf(wxT("File times for '%s':\n"), fn.GetFullPath().c_str());
820 wxPrintf(wxT("Creation: \t%s\n"), dtCreate.Format(fmt).c_str());
821 wxPrintf(wxT("Last read: \t%s\n"), dtAccess.Format(fmt).c_str());
822 wxPrintf(wxT("Last write: \t%s\n"), dtMod.Format(fmt).c_str());
823 }
824 }
825
826 #if 0
827 static void TestFileSetTimes()
828 {
829 wxFileName fn(wxT("testdata.fc"));
830
831 if ( !fn.Touch() )
832 {
833 wxPrintf(wxT("ERROR: Touch() failed.\n"));
834 }
835 }
836 #endif
837
838 #endif // TEST_FILETIME
839
840 // ----------------------------------------------------------------------------
841 // wxLocale
842 // ----------------------------------------------------------------------------
843
844 #ifdef TEST_LOCALE
845
846 #include "wx/intl.h"
847 #include "wx/utils.h" // for wxSetEnv
848
849 static wxLocale gs_localeDefault;
850 // NOTE: don't init it here as it needs a wxAppTraits object
851 // and thus must be init-ed after creation of the wxInitializer
852 // class in the main()
853
854 // find the name of the language from its value
855 static const wxChar *GetLangName(int lang)
856 {
857 static const wxChar *languageNames[] =
858 {
859 wxT("DEFAULT"),
860 wxT("UNKNOWN"),
861 wxT("ABKHAZIAN"),
862 wxT("AFAR"),
863 wxT("AFRIKAANS"),
864 wxT("ALBANIAN"),
865 wxT("AMHARIC"),
866 wxT("ARABIC"),
867 wxT("ARABIC_ALGERIA"),
868 wxT("ARABIC_BAHRAIN"),
869 wxT("ARABIC_EGYPT"),
870 wxT("ARABIC_IRAQ"),
871 wxT("ARABIC_JORDAN"),
872 wxT("ARABIC_KUWAIT"),
873 wxT("ARABIC_LEBANON"),
874 wxT("ARABIC_LIBYA"),
875 wxT("ARABIC_MOROCCO"),
876 wxT("ARABIC_OMAN"),
877 wxT("ARABIC_QATAR"),
878 wxT("ARABIC_SAUDI_ARABIA"),
879 wxT("ARABIC_SUDAN"),
880 wxT("ARABIC_SYRIA"),
881 wxT("ARABIC_TUNISIA"),
882 wxT("ARABIC_UAE"),
883 wxT("ARABIC_YEMEN"),
884 wxT("ARMENIAN"),
885 wxT("ASSAMESE"),
886 wxT("AYMARA"),
887 wxT("AZERI"),
888 wxT("AZERI_CYRILLIC"),
889 wxT("AZERI_LATIN"),
890 wxT("BASHKIR"),
891 wxT("BASQUE"),
892 wxT("BELARUSIAN"),
893 wxT("BENGALI"),
894 wxT("BHUTANI"),
895 wxT("BIHARI"),
896 wxT("BISLAMA"),
897 wxT("BRETON"),
898 wxT("BULGARIAN"),
899 wxT("BURMESE"),
900 wxT("CAMBODIAN"),
901 wxT("CATALAN"),
902 wxT("CHINESE"),
903 wxT("CHINESE_SIMPLIFIED"),
904 wxT("CHINESE_TRADITIONAL"),
905 wxT("CHINESE_HONGKONG"),
906 wxT("CHINESE_MACAU"),
907 wxT("CHINESE_SINGAPORE"),
908 wxT("CHINESE_TAIWAN"),
909 wxT("CORSICAN"),
910 wxT("CROATIAN"),
911 wxT("CZECH"),
912 wxT("DANISH"),
913 wxT("DUTCH"),
914 wxT("DUTCH_BELGIAN"),
915 wxT("ENGLISH"),
916 wxT("ENGLISH_UK"),
917 wxT("ENGLISH_US"),
918 wxT("ENGLISH_AUSTRALIA"),
919 wxT("ENGLISH_BELIZE"),
920 wxT("ENGLISH_BOTSWANA"),
921 wxT("ENGLISH_CANADA"),
922 wxT("ENGLISH_CARIBBEAN"),
923 wxT("ENGLISH_DENMARK"),
924 wxT("ENGLISH_EIRE"),
925 wxT("ENGLISH_JAMAICA"),
926 wxT("ENGLISH_NEW_ZEALAND"),
927 wxT("ENGLISH_PHILIPPINES"),
928 wxT("ENGLISH_SOUTH_AFRICA"),
929 wxT("ENGLISH_TRINIDAD"),
930 wxT("ENGLISH_ZIMBABWE"),
931 wxT("ESPERANTO"),
932 wxT("ESTONIAN"),
933 wxT("FAEROESE"),
934 wxT("FARSI"),
935 wxT("FIJI"),
936 wxT("FINNISH"),
937 wxT("FRENCH"),
938 wxT("FRENCH_BELGIAN"),
939 wxT("FRENCH_CANADIAN"),
940 wxT("FRENCH_LUXEMBOURG"),
941 wxT("FRENCH_MONACO"),
942 wxT("FRENCH_SWISS"),
943 wxT("FRISIAN"),
944 wxT("GALICIAN"),
945 wxT("GEORGIAN"),
946 wxT("GERMAN"),
947 wxT("GERMAN_AUSTRIAN"),
948 wxT("GERMAN_BELGIUM"),
949 wxT("GERMAN_LIECHTENSTEIN"),
950 wxT("GERMAN_LUXEMBOURG"),
951 wxT("GERMAN_SWISS"),
952 wxT("GREEK"),
953 wxT("GREENLANDIC"),
954 wxT("GUARANI"),
955 wxT("GUJARATI"),
956 wxT("HAUSA"),
957 wxT("HEBREW"),
958 wxT("HINDI"),
959 wxT("HUNGARIAN"),
960 wxT("ICELANDIC"),
961 wxT("INDONESIAN"),
962 wxT("INTERLINGUA"),
963 wxT("INTERLINGUE"),
964 wxT("INUKTITUT"),
965 wxT("INUPIAK"),
966 wxT("IRISH"),
967 wxT("ITALIAN"),
968 wxT("ITALIAN_SWISS"),
969 wxT("JAPANESE"),
970 wxT("JAVANESE"),
971 wxT("KANNADA"),
972 wxT("KASHMIRI"),
973 wxT("KASHMIRI_INDIA"),
974 wxT("KAZAKH"),
975 wxT("KERNEWEK"),
976 wxT("KINYARWANDA"),
977 wxT("KIRGHIZ"),
978 wxT("KIRUNDI"),
979 wxT("KONKANI"),
980 wxT("KOREAN"),
981 wxT("KURDISH"),
982 wxT("LAOTHIAN"),
983 wxT("LATIN"),
984 wxT("LATVIAN"),
985 wxT("LINGALA"),
986 wxT("LITHUANIAN"),
987 wxT("MACEDONIAN"),
988 wxT("MALAGASY"),
989 wxT("MALAY"),
990 wxT("MALAYALAM"),
991 wxT("MALAY_BRUNEI_DARUSSALAM"),
992 wxT("MALAY_MALAYSIA"),
993 wxT("MALTESE"),
994 wxT("MANIPURI"),
995 wxT("MAORI"),
996 wxT("MARATHI"),
997 wxT("MOLDAVIAN"),
998 wxT("MONGOLIAN"),
999 wxT("NAURU"),
1000 wxT("NEPALI"),
1001 wxT("NEPALI_INDIA"),
1002 wxT("NORWEGIAN_BOKMAL"),
1003 wxT("NORWEGIAN_NYNORSK"),
1004 wxT("OCCITAN"),
1005 wxT("ORIYA"),
1006 wxT("OROMO"),
1007 wxT("PASHTO"),
1008 wxT("POLISH"),
1009 wxT("PORTUGUESE"),
1010 wxT("PORTUGUESE_BRAZILIAN"),
1011 wxT("PUNJABI"),
1012 wxT("QUECHUA"),
1013 wxT("RHAETO_ROMANCE"),
1014 wxT("ROMANIAN"),
1015 wxT("RUSSIAN"),
1016 wxT("RUSSIAN_UKRAINE"),
1017 wxT("SAMOAN"),
1018 wxT("SANGHO"),
1019 wxT("SANSKRIT"),
1020 wxT("SCOTS_GAELIC"),
1021 wxT("SERBIAN"),
1022 wxT("SERBIAN_CYRILLIC"),
1023 wxT("SERBIAN_LATIN"),
1024 wxT("SERBO_CROATIAN"),
1025 wxT("SESOTHO"),
1026 wxT("SETSWANA"),
1027 wxT("SHONA"),
1028 wxT("SINDHI"),
1029 wxT("SINHALESE"),
1030 wxT("SISWATI"),
1031 wxT("SLOVAK"),
1032 wxT("SLOVENIAN"),
1033 wxT("SOMALI"),
1034 wxT("SPANISH"),
1035 wxT("SPANISH_ARGENTINA"),
1036 wxT("SPANISH_BOLIVIA"),
1037 wxT("SPANISH_CHILE"),
1038 wxT("SPANISH_COLOMBIA"),
1039 wxT("SPANISH_COSTA_RICA"),
1040 wxT("SPANISH_DOMINICAN_REPUBLIC"),
1041 wxT("SPANISH_ECUADOR"),
1042 wxT("SPANISH_EL_SALVADOR"),
1043 wxT("SPANISH_GUATEMALA"),
1044 wxT("SPANISH_HONDURAS"),
1045 wxT("SPANISH_MEXICAN"),
1046 wxT("SPANISH_MODERN"),
1047 wxT("SPANISH_NICARAGUA"),
1048 wxT("SPANISH_PANAMA"),
1049 wxT("SPANISH_PARAGUAY"),
1050 wxT("SPANISH_PERU"),
1051 wxT("SPANISH_PUERTO_RICO"),
1052 wxT("SPANISH_URUGUAY"),
1053 wxT("SPANISH_US"),
1054 wxT("SPANISH_VENEZUELA"),
1055 wxT("SUNDANESE"),
1056 wxT("SWAHILI"),
1057 wxT("SWEDISH"),
1058 wxT("SWEDISH_FINLAND"),
1059 wxT("TAGALOG"),
1060 wxT("TAJIK"),
1061 wxT("TAMIL"),
1062 wxT("TATAR"),
1063 wxT("TELUGU"),
1064 wxT("THAI"),
1065 wxT("TIBETAN"),
1066 wxT("TIGRINYA"),
1067 wxT("TONGA"),
1068 wxT("TSONGA"),
1069 wxT("TURKISH"),
1070 wxT("TURKMEN"),
1071 wxT("TWI"),
1072 wxT("UIGHUR"),
1073 wxT("UKRAINIAN"),
1074 wxT("URDU"),
1075 wxT("URDU_INDIA"),
1076 wxT("URDU_PAKISTAN"),
1077 wxT("UZBEK"),
1078 wxT("UZBEK_CYRILLIC"),
1079 wxT("UZBEK_LATIN"),
1080 wxT("VIETNAMESE"),
1081 wxT("VOLAPUK"),
1082 wxT("WELSH"),
1083 wxT("WOLOF"),
1084 wxT("XHOSA"),
1085 wxT("YIDDISH"),
1086 wxT("YORUBA"),
1087 wxT("ZHUANG"),
1088 wxT("ZULU"),
1089 };
1090
1091 if ( (size_t)lang < WXSIZEOF(languageNames) )
1092 return languageNames[lang];
1093 else
1094 return wxT("INVALID");
1095 }
1096
1097 static void TestDefaultLang()
1098 {
1099 wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
1100
1101 gs_localeDefault.Init(wxLANGUAGE_ENGLISH);
1102
1103 static const wxChar *langStrings[] =
1104 {
1105 NULL, // system default
1106 wxT("C"),
1107 wxT("fr"),
1108 wxT("fr_FR"),
1109 wxT("en"),
1110 wxT("en_GB"),
1111 wxT("en_US"),
1112 wxT("de_DE.iso88591"),
1113 wxT("german"),
1114 wxT("?"), // invalid lang spec
1115 wxT("klingonese"), // I bet on some systems it does exist...
1116 };
1117
1118 wxPrintf(wxT("The default system encoding is %s (%d)\n"),
1119 wxLocale::GetSystemEncodingName().c_str(),
1120 wxLocale::GetSystemEncoding());
1121
1122 for ( size_t n = 0; n < WXSIZEOF(langStrings); n++ )
1123 {
1124 const wxChar *langStr = langStrings[n];
1125 if ( langStr )
1126 {
1127 // FIXME: this doesn't do anything at all under Windows, we need
1128 // to create a new wxLocale!
1129 wxSetEnv(wxT("LC_ALL"), langStr);
1130 }
1131
1132 int lang = gs_localeDefault.GetSystemLanguage();
1133 wxPrintf(wxT("Locale for '%s' is %s.\n"),
1134 langStr ? langStr : wxT("system default"), GetLangName(lang));
1135 }
1136 }
1137
1138 #endif // TEST_LOCALE
1139
1140 // ----------------------------------------------------------------------------
1141 // MIME types
1142 // ----------------------------------------------------------------------------
1143
1144 #ifdef TEST_MIME
1145
1146 #include "wx/mimetype.h"
1147
1148 static void TestMimeEnum()
1149 {
1150 wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1151
1152 wxArrayString mimetypes;
1153
1154 size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
1155
1156 wxPrintf(wxT("*** All %u known filetypes: ***\n"), count);
1157
1158 wxArrayString exts;
1159 wxString desc;
1160
1161 for ( size_t n = 0; n < count; n++ )
1162 {
1163 wxFileType *filetype =
1164 wxTheMimeTypesManager->GetFileTypeFromMimeType(mimetypes[n]);
1165 if ( !filetype )
1166 {
1167 wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
1168 mimetypes[n].c_str());
1169 continue;
1170 }
1171
1172 filetype->GetDescription(&desc);
1173 filetype->GetExtensions(exts);
1174
1175 filetype->GetIcon(NULL);
1176
1177 wxString extsAll;
1178 for ( size_t e = 0; e < exts.GetCount(); e++ )
1179 {
1180 if ( e > 0 )
1181 extsAll << wxT(", ");
1182 extsAll += exts[e];
1183 }
1184
1185 wxPrintf(wxT("\t%s: %s (%s)\n"),
1186 mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
1187 }
1188
1189 wxPuts(wxEmptyString);
1190 }
1191
1192 static void TestMimeFilename()
1193 {
1194 wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
1195
1196 static const wxChar *filenames[] =
1197 {
1198 wxT("readme.txt"),
1199 wxT("document.pdf"),
1200 wxT("image.gif"),
1201 wxT("picture.jpeg"),
1202 };
1203
1204 for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
1205 {
1206 const wxString fname = filenames[n];
1207 wxString ext = fname.AfterLast(wxT('.'));
1208 wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
1209 if ( !ft )
1210 {
1211 wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext.c_str());
1212 }
1213 else
1214 {
1215 wxString desc;
1216 if ( !ft->GetDescription(&desc) )
1217 desc = wxT("<no description>");
1218
1219 wxString cmd;
1220 if ( !ft->GetOpenCommand(&cmd,
1221 wxFileType::MessageParameters(fname, wxEmptyString)) )
1222 cmd = wxT("<no command available>");
1223 else
1224 cmd = wxString(wxT('"')) + cmd + wxT('"');
1225
1226 wxPrintf(wxT("To open %s (%s) do %s.\n"),
1227 fname.c_str(), desc.c_str(), cmd.c_str());
1228
1229 delete ft;
1230 }
1231 }
1232
1233 wxPuts(wxEmptyString);
1234 }
1235
1236 // these tests were broken by wxMimeTypesManager changes, temporarily disabling
1237 #if 0
1238
1239 static void TestMimeOverride()
1240 {
1241 wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
1242
1243 static const wxChar *mailcap = wxT("/tmp/mailcap");
1244 static const wxChar *mimetypes = wxT("/tmp/mime.types");
1245
1246 if ( wxFile::Exists(mailcap) )
1247 wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
1248 mailcap,
1249 wxTheMimeTypesManager->ReadMailcap(mailcap) ? wxT("ok") : wxT("ERROR"));
1250 else
1251 wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1252 mailcap);
1253
1254 if ( wxFile::Exists(mimetypes) )
1255 wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
1256 mimetypes,
1257 wxTheMimeTypesManager->ReadMimeTypes(mimetypes) ? wxT("ok") : wxT("ERROR"));
1258 else
1259 wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1260 mimetypes);
1261
1262 wxPuts(wxEmptyString);
1263 }
1264
1265 static void TestMimeAssociate()
1266 {
1267 wxPuts(wxT("*** Testing creation of filetype association ***\n"));
1268
1269 wxFileTypeInfo ftInfo(
1270 wxT("application/x-xyz"),
1271 wxT("xyzview '%s'"), // open cmd
1272 wxT(""), // print cmd
1273 wxT("XYZ File"), // description
1274 wxT(".xyz"), // extensions
1275 wxNullPtr // end of extensions
1276 );
1277 ftInfo.SetShortDesc(wxT("XYZFile")); // used under Win32 only
1278
1279 wxFileType *ft = wxTheMimeTypesManager->Associate(ftInfo);
1280 if ( !ft )
1281 {
1282 wxPuts(wxT("ERROR: failed to create association!"));
1283 }
1284 else
1285 {
1286 // TODO: read it back
1287 delete ft;
1288 }
1289
1290 wxPuts(wxEmptyString);
1291 }
1292
1293 #endif // 0
1294
1295 #endif // TEST_MIME
1296
1297 // ----------------------------------------------------------------------------
1298 // module dependencies feature
1299 // ----------------------------------------------------------------------------
1300
1301 #ifdef TEST_MODULE
1302
1303 #include "wx/module.h"
1304
1305 class wxTestModule : public wxModule
1306 {
1307 protected:
1308 virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
1309 virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
1310 };
1311
1312 class wxTestModuleA : public wxTestModule
1313 {
1314 public:
1315 wxTestModuleA();
1316 private:
1317 DECLARE_DYNAMIC_CLASS(wxTestModuleA)
1318 };
1319
1320 class wxTestModuleB : public wxTestModule
1321 {
1322 public:
1323 wxTestModuleB();
1324 private:
1325 DECLARE_DYNAMIC_CLASS(wxTestModuleB)
1326 };
1327
1328 class wxTestModuleC : public wxTestModule
1329 {
1330 public:
1331 wxTestModuleC();
1332 private:
1333 DECLARE_DYNAMIC_CLASS(wxTestModuleC)
1334 };
1335
1336 class wxTestModuleD : public wxTestModule
1337 {
1338 public:
1339 wxTestModuleD();
1340 private:
1341 DECLARE_DYNAMIC_CLASS(wxTestModuleD)
1342 };
1343
1344 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC, wxModule)
1345 wxTestModuleC::wxTestModuleC()
1346 {
1347 AddDependency(CLASSINFO(wxTestModuleD));
1348 }
1349
1350 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA, wxModule)
1351 wxTestModuleA::wxTestModuleA()
1352 {
1353 AddDependency(CLASSINFO(wxTestModuleB));
1354 AddDependency(CLASSINFO(wxTestModuleD));
1355 }
1356
1357 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD, wxModule)
1358 wxTestModuleD::wxTestModuleD()
1359 {
1360 }
1361
1362 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB, wxModule)
1363 wxTestModuleB::wxTestModuleB()
1364 {
1365 AddDependency(CLASSINFO(wxTestModuleD));
1366 AddDependency(CLASSINFO(wxTestModuleC));
1367 }
1368
1369 #endif // TEST_MODULE
1370
1371 // ----------------------------------------------------------------------------
1372 // misc information functions
1373 // ----------------------------------------------------------------------------
1374
1375 #ifdef TEST_INFO_FUNCTIONS
1376
1377 #include "wx/utils.h"
1378
1379 #if TEST_INTERACTIVE
1380 static void TestDiskInfo()
1381 {
1382 wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
1383
1384 for ( ;; )
1385 {
1386 wxChar pathname[128];
1387 wxPrintf(wxT("\nEnter a directory name: "));
1388 if ( !wxFgets(pathname, WXSIZEOF(pathname), stdin) )
1389 break;
1390
1391 // kill the last '\n'
1392 pathname[wxStrlen(pathname) - 1] = 0;
1393
1394 wxLongLong total, free;
1395 if ( !wxGetDiskSpace(pathname, &total, &free) )
1396 {
1397 wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
1398 }
1399 else
1400 {
1401 wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
1402 (total / 1024).ToString().c_str(),
1403 (free / 1024).ToString().c_str(),
1404 pathname);
1405 }
1406 }
1407 }
1408 #endif // TEST_INTERACTIVE
1409
1410 static void TestOsInfo()
1411 {
1412 wxPuts(wxT("*** Testing OS info functions ***\n"));
1413
1414 int major, minor;
1415 wxGetOsVersion(&major, &minor);
1416 wxPrintf(wxT("Running under: %s, version %d.%d\n"),
1417 wxGetOsDescription().c_str(), major, minor);
1418
1419 wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1420
1421 wxPrintf(wxT("Host name is %s (%s).\n"),
1422 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1423
1424 wxPuts(wxEmptyString);
1425 }
1426
1427 static void TestPlatformInfo()
1428 {
1429 wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
1430
1431 // get this platform
1432 wxPlatformInfo plat;
1433
1434 wxPrintf(wxT("Operating system family name is: %s\n"), plat.GetOperatingSystemFamilyName().c_str());
1435 wxPrintf(wxT("Operating system name is: %s\n"), plat.GetOperatingSystemIdName().c_str());
1436 wxPrintf(wxT("Port ID name is: %s\n"), plat.GetPortIdName().c_str());
1437 wxPrintf(wxT("Port ID short name is: %s\n"), plat.GetPortIdShortName().c_str());
1438 wxPrintf(wxT("Architecture is: %s\n"), plat.GetArchName().c_str());
1439 wxPrintf(wxT("Endianness is: %s\n"), plat.GetEndiannessName().c_str());
1440
1441 wxPuts(wxEmptyString);
1442 }
1443
1444 static void TestUserInfo()
1445 {
1446 wxPuts(wxT("*** Testing user info functions ***\n"));
1447
1448 wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
1449 wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
1450 wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
1451 wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());
1452
1453 wxPuts(wxEmptyString);
1454 }
1455
1456 #endif // TEST_INFO_FUNCTIONS
1457
1458 // ----------------------------------------------------------------------------
1459 // path list
1460 // ----------------------------------------------------------------------------
1461
1462 #ifdef TEST_PATHLIST
1463
1464 #ifdef __UNIX__
1465 #define CMD_IN_PATH wxT("ls")
1466 #else
1467 #define CMD_IN_PATH wxT("command.com")
1468 #endif
1469
1470 static void TestPathList()
1471 {
1472 wxPuts(wxT("*** Testing wxPathList ***\n"));
1473
1474 wxPathList pathlist;
1475 pathlist.AddEnvList(wxT("PATH"));
1476 wxString path = pathlist.FindValidPath(CMD_IN_PATH);
1477 if ( path.empty() )
1478 {
1479 wxPrintf(wxT("ERROR: command not found in the path.\n"));
1480 }
1481 else
1482 {
1483 wxPrintf(wxT("Command found in the path as '%s'.\n"), path.c_str());
1484 }
1485 }
1486
1487 #endif // TEST_PATHLIST
1488
1489 // ----------------------------------------------------------------------------
1490 // regular expressions
1491 // ----------------------------------------------------------------------------
1492
1493 #if defined TEST_REGEX && TEST_INTERACTIVE
1494
1495 #include "wx/regex.h"
1496
1497 static void TestRegExInteractive()
1498 {
1499 wxPuts(wxT("*** Testing RE interactively ***"));
1500
1501 for ( ;; )
1502 {
1503 wxChar pattern[128];
1504 wxPrintf(wxT("\nEnter a pattern: "));
1505 if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
1506 break;
1507
1508 // kill the last '\n'
1509 pattern[wxStrlen(pattern) - 1] = 0;
1510
1511 wxRegEx re;
1512 if ( !re.Compile(pattern) )
1513 {
1514 continue;
1515 }
1516
1517 wxChar text[128];
1518 for ( ;; )
1519 {
1520 wxPrintf(wxT("Enter text to match: "));
1521 if ( !wxFgets(text, WXSIZEOF(text), stdin) )
1522 break;
1523
1524 // kill the last '\n'
1525 text[wxStrlen(text) - 1] = 0;
1526
1527 if ( !re.Matches(text) )
1528 {
1529 wxPrintf(wxT("No match.\n"));
1530 }
1531 else
1532 {
1533 wxPrintf(wxT("Pattern matches at '%s'\n"), re.GetMatch(text).c_str());
1534
1535 size_t start, len;
1536 for ( size_t n = 1; ; n++ )
1537 {
1538 if ( !re.GetMatch(&start, &len, n) )
1539 {
1540 break;
1541 }
1542
1543 wxPrintf(wxT("Subexpr %u matched '%s'\n"),
1544 n, wxString(text + start, len).c_str());
1545 }
1546 }
1547 }
1548 }
1549 }
1550
1551 #endif // TEST_REGEX
1552
1553 // ----------------------------------------------------------------------------
1554 // FTP
1555 // ----------------------------------------------------------------------------
1556
1557 #ifdef TEST_FTP
1558
1559 #include "wx/protocol/ftp.h"
1560 #include "wx/protocol/log.h"
1561
1562 #define FTP_ANONYMOUS
1563
1564 static wxFTP *ftp;
1565
1566 #ifdef FTP_ANONYMOUS
1567 static const wxChar *hostname = wxT("ftp.wxwidgets.org");
1568 static const wxChar *directory = wxT("/pub");
1569 static const wxChar *filename = wxT("welcome.msg");
1570 #else
1571 static const wxChar *hostname = "localhost";
1572 static const wxChar *directory = wxT("/etc");
1573 static const wxChar *filename = wxT("issue");
1574 #endif
1575
1576 static bool TestFtpConnect()
1577 {
1578 wxPuts(wxT("*** Testing FTP connect ***"));
1579
1580 #ifdef FTP_ANONYMOUS
1581 wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
1582 #else // !FTP_ANONYMOUS
1583 wxChar user[256];
1584 wxFgets(user, WXSIZEOF(user), stdin);
1585 user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
1586 ftp->SetUser(user);
1587
1588 wxChar password[256];
1589 wxPrintf(wxT("Password for %s: "), password);
1590 wxFgets(password, WXSIZEOF(password), stdin);
1591 password[wxStrlen(password) - 1] = '\0'; // chop off '\n'
1592 ftp->SetPassword(password);
1593
1594 wxPrintf(wxT("--- Attempting to connect to %s:21 as %s...\n"), hostname, user);
1595 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
1596
1597 if ( !ftp->Connect(hostname) )
1598 {
1599 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname);
1600
1601 return false;
1602 }
1603 else
1604 {
1605 wxPrintf(wxT("--- Connected to %s, current directory is '%s'\n"),
1606 hostname, ftp->Pwd().c_str());
1607 ftp->Close();
1608 }
1609
1610 return true;
1611 }
1612
1613 #if TEST_INTERACTIVE
1614 static void TestFtpInteractive()
1615 {
1616 wxPuts(wxT("\n*** Interactive wxFTP test ***"));
1617
1618 wxChar buf[128];
1619
1620 for ( ;; )
1621 {
1622 wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
1623 if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
1624 break;
1625
1626 // kill the last '\n'
1627 buf[wxStrlen(buf) - 1] = 0;
1628
1629 // special handling of LIST and NLST as they require data connection
1630 wxString start(buf, 4);
1631 start.MakeUpper();
1632 if ( start == wxT("LIST") || start == wxT("NLST") )
1633 {
1634 wxString wildcard;
1635 if ( wxStrlen(buf) > 4 )
1636 wildcard = buf + 5;
1637
1638 wxArrayString files;
1639 if ( !ftp->GetList(files, wildcard, start == wxT("LIST")) )
1640 {
1641 wxPrintf(wxT("ERROR: failed to get %s of files\n"), start.c_str());
1642 }
1643 else
1644 {
1645 wxPrintf(wxT("--- %s of '%s' under '%s':\n"),
1646 start.c_str(), wildcard.c_str(), ftp->Pwd().c_str());
1647 size_t count = files.GetCount();
1648 for ( size_t n = 0; n < count; n++ )
1649 {
1650 wxPrintf(wxT("\t%s\n"), files[n].c_str());
1651 }
1652 wxPuts(wxT("--- End of the file list"));
1653 }
1654 }
1655 else if ( start == wxT("QUIT") )
1656 {
1657 break; // get out of here!
1658 }
1659 else // !list
1660 {
1661 wxChar ch = ftp->SendCommand(buf);
1662 wxPrintf(wxT("Command %s"), ch ? wxT("succeeded") : wxT("failed"));
1663 if ( ch )
1664 {
1665 wxPrintf(wxT(" (return code %c)"), ch);
1666 }
1667
1668 wxPrintf(wxT(", server reply:\n%s\n\n"), ftp->GetLastResult().c_str());
1669 }
1670 }
1671
1672 wxPuts(wxT("\n"));
1673 }
1674 #endif // TEST_INTERACTIVE
1675 #endif // TEST_FTP
1676
1677 // ----------------------------------------------------------------------------
1678 // stack backtrace
1679 // ----------------------------------------------------------------------------
1680
1681 #ifdef TEST_STACKWALKER
1682
1683 #if wxUSE_STACKWALKER
1684
1685 #include "wx/stackwalk.h"
1686
1687 class StackDump : public wxStackWalker
1688 {
1689 public:
1690 StackDump(const char *argv0)
1691 : wxStackWalker(argv0)
1692 {
1693 }
1694
1695 virtual void Walk(size_t skip = 1, size_t maxdepth = wxSTACKWALKER_MAX_DEPTH)
1696 {
1697 wxPuts(wxT("Stack dump:"));
1698
1699 wxStackWalker::Walk(skip, maxdepth);
1700 }
1701
1702 protected:
1703 virtual void OnStackFrame(const wxStackFrame& frame)
1704 {
1705 printf("[%2d] ", (int) frame.GetLevel());
1706
1707 wxString name = frame.GetName();
1708 if ( !name.empty() )
1709 {
1710 printf("%-20.40s", (const char*)name.mb_str());
1711 }
1712 else
1713 {
1714 printf("0x%08lx", (unsigned long)frame.GetAddress());
1715 }
1716
1717 if ( frame.HasSourceLocation() )
1718 {
1719 printf("\t%s:%d",
1720 (const char*)frame.GetFileName().mb_str(),
1721 (int)frame.GetLine());
1722 }
1723
1724 puts("");
1725
1726 wxString type, val;
1727 for ( size_t n = 0; frame.GetParam(n, &type, &name, &val); n++ )
1728 {
1729 printf("\t%s %s = %s\n", (const char*)type.mb_str(),
1730 (const char*)name.mb_str(),
1731 (const char*)val.mb_str());
1732 }
1733 }
1734 };
1735
1736 static void TestStackWalk(const char *argv0)
1737 {
1738 wxPuts(wxT("*** Testing wxStackWalker ***"));
1739
1740 StackDump dump(argv0);
1741 dump.Walk();
1742
1743 wxPuts("\n");
1744 }
1745
1746 #endif // wxUSE_STACKWALKER
1747
1748 #endif // TEST_STACKWALKER
1749
1750 // ----------------------------------------------------------------------------
1751 // standard paths
1752 // ----------------------------------------------------------------------------
1753
1754 #ifdef TEST_STDPATHS
1755
1756 #include "wx/stdpaths.h"
1757 #include "wx/wxchar.h" // wxPrintf
1758
1759 static void TestStandardPaths()
1760 {
1761 wxPuts(wxT("*** Testing wxStandardPaths ***"));
1762
1763 wxTheApp->SetAppName(wxT("console"));
1764
1765 wxStandardPathsBase& stdp = wxStandardPaths::Get();
1766 wxPrintf(wxT("Config dir (sys):\t%s\n"), stdp.GetConfigDir().c_str());
1767 wxPrintf(wxT("Config dir (user):\t%s\n"), stdp.GetUserConfigDir().c_str());
1768 wxPrintf(wxT("Data dir (sys):\t\t%s\n"), stdp.GetDataDir().c_str());
1769 wxPrintf(wxT("Data dir (sys local):\t%s\n"), stdp.GetLocalDataDir().c_str());
1770 wxPrintf(wxT("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str());
1771 wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str());
1772 wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str());
1773 wxPrintf(wxT("Executable path:\t%s\n"), stdp.GetExecutablePath().c_str());
1774 wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir().c_str());
1775 wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str());
1776 wxPrintf(wxT("Localized res. dir:\t%s\n"),
1777 stdp.GetLocalizedResourcesDir(wxT("fr")).c_str());
1778 wxPrintf(wxT("Message catalogs dir:\t%s\n"),
1779 stdp.GetLocalizedResourcesDir
1780 (
1781 wxT("fr"),
1782 wxStandardPaths::ResourceCat_Messages
1783 ).c_str());
1784
1785 wxPuts("\n");
1786 }
1787
1788 #endif // TEST_STDPATHS
1789
1790 // ----------------------------------------------------------------------------
1791 // wxVolume tests
1792 // ----------------------------------------------------------------------------
1793
1794 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
1795 #undef TEST_VOLUME
1796 #endif
1797
1798 #ifdef TEST_VOLUME
1799
1800 #include "wx/volume.h"
1801
1802 static const wxChar *volumeKinds[] =
1803 {
1804 wxT("floppy"),
1805 wxT("hard disk"),
1806 wxT("CD-ROM"),
1807 wxT("DVD-ROM"),
1808 wxT("network volume"),
1809 wxT("other volume"),
1810 };
1811
1812 static void TestFSVolume()
1813 {
1814 wxPuts(wxT("*** Testing wxFSVolume class ***"));
1815
1816 wxArrayString volumes = wxFSVolume::GetVolumes();
1817 size_t count = volumes.GetCount();
1818
1819 if ( !count )
1820 {
1821 wxPuts(wxT("ERROR: no mounted volumes?"));
1822 return;
1823 }
1824
1825 wxPrintf(wxT("%u mounted volumes found:\n"), count);
1826
1827 for ( size_t n = 0; n < count; n++ )
1828 {
1829 wxFSVolume vol(volumes[n]);
1830 if ( !vol.IsOk() )
1831 {
1832 wxPuts(wxT("ERROR: couldn't create volume"));
1833 continue;
1834 }
1835
1836 wxPrintf(wxT("%u: %s (%s), %s, %s, %s\n"),
1837 n + 1,
1838 vol.GetDisplayName().c_str(),
1839 vol.GetName().c_str(),
1840 volumeKinds[vol.GetKind()],
1841 vol.IsWritable() ? wxT("rw") : wxT("ro"),
1842 vol.GetFlags() & wxFS_VOL_REMOVABLE ? wxT("removable")
1843 : wxT("fixed"));
1844 }
1845
1846 wxPuts("\n");
1847 }
1848
1849 #endif // TEST_VOLUME
1850
1851 // ----------------------------------------------------------------------------
1852 // date time
1853 // ----------------------------------------------------------------------------
1854
1855 #ifdef TEST_DATETIME
1856
1857 #include "wx/math.h"
1858 #include "wx/datetime.h"
1859
1860 #if TEST_INTERACTIVE
1861
1862 static void TestDateTimeInteractive()
1863 {
1864 wxPuts(wxT("\n*** interactive wxDateTime tests ***"));
1865
1866 wxChar buf[128];
1867
1868 for ( ;; )
1869 {
1870 wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
1871 if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
1872 break;
1873
1874 // kill the last '\n'
1875 buf[wxStrlen(buf) - 1] = 0;
1876
1877 if ( wxString(buf).CmpNoCase("quit") == 0 )
1878 break;
1879
1880 wxDateTime dt;
1881 const wxChar *p = dt.ParseDate(buf);
1882 if ( !p )
1883 {
1884 wxPrintf(wxT("ERROR: failed to parse the date '%s'.\n"), buf);
1885
1886 continue;
1887 }
1888 else if ( *p )
1889 {
1890 wxPrintf(wxT("WARNING: parsed only first %u characters.\n"), p - buf);
1891 }
1892
1893 wxPrintf(wxT("%s: day %u, week of month %u/%u, week of year %u\n"),
1894 dt.Format(wxT("%b %d, %Y")).c_str(),
1895 dt.GetDayOfYear(),
1896 dt.GetWeekOfMonth(wxDateTime::Monday_First),
1897 dt.GetWeekOfMonth(wxDateTime::Sunday_First),
1898 dt.GetWeekOfYear(wxDateTime::Monday_First));
1899 }
1900
1901 wxPuts("\n");
1902 }
1903
1904 #endif // TEST_INTERACTIVE
1905 #endif // TEST_DATETIME
1906
1907 // ----------------------------------------------------------------------------
1908 // single instance
1909 // ----------------------------------------------------------------------------
1910
1911 #ifdef TEST_SNGLINST
1912
1913 #include "wx/snglinst.h"
1914
1915 static bool TestSingleIstance()
1916 {
1917 wxPuts(wxT("\n*** Testing wxSingleInstanceChecker ***"));
1918
1919 wxSingleInstanceChecker checker;
1920 if ( checker.Create(wxT(".wxconsole.lock")) )
1921 {
1922 if ( checker.IsAnotherRunning() )
1923 {
1924 wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
1925
1926 return false;
1927 }
1928
1929 // wait some time to give time to launch another instance
1930 wxPuts(wxT("If you try to run another instance of this program now, it won't start."));
1931 wxPrintf(wxT("Press \"Enter\" to exit wxSingleInstanceChecker test and proceed..."));
1932 wxFgetc(stdin);
1933 }
1934 else // failed to create
1935 {
1936 wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
1937 }
1938
1939 wxPuts("\n");
1940
1941 return true;
1942 }
1943 #endif // TEST_SNGLINST
1944
1945
1946 // ----------------------------------------------------------------------------
1947 // entry point
1948 // ----------------------------------------------------------------------------
1949
1950 int main(int argc, char **argv)
1951 {
1952 #if wxUSE_UNICODE
1953 wxChar **wxArgv = new wxChar *[argc + 1];
1954
1955 {
1956 int n;
1957
1958 for (n = 0; n < argc; n++ )
1959 {
1960 wxMB2WXbuf warg = wxConvertMB2WX(argv[n]);
1961 wxArgv[n] = wxStrdup(warg);
1962 }
1963
1964 wxArgv[n] = NULL;
1965 }
1966 #else // !wxUSE_UNICODE
1967 #define wxArgv argv
1968 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
1969
1970 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
1971
1972 wxInitializer initializer;
1973 if ( !initializer )
1974 {
1975 fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
1976
1977 return -1;
1978 }
1979
1980 #ifdef TEST_SNGLINST
1981 if (!TestSingleIstance())
1982 return 1;
1983 #endif // TEST_SNGLINST
1984
1985 #ifdef TEST_DIR
1986 #if TEST_ALL
1987 TestDirExists();
1988 TestDirEnum();
1989 #endif
1990 TestDirTraverse();
1991 #endif // TEST_DIR
1992
1993 #ifdef TEST_DYNLIB
1994 TestDllLoad();
1995 TestDllListLoaded();
1996 #endif // TEST_DYNLIB
1997
1998 #ifdef TEST_ENVIRON
1999 TestEnvironment();
2000 #endif // TEST_ENVIRON
2001
2002 #ifdef TEST_FILECONF
2003 TestFileConfRead();
2004 #endif // TEST_FILECONF
2005
2006 #ifdef TEST_LOCALE
2007 TestDefaultLang();
2008 #endif // TEST_LOCALE
2009
2010 #ifdef TEST_LOG
2011 wxPuts(wxT("*** Testing wxLog ***"));
2012
2013 wxString s;
2014 for ( size_t n = 0; n < 8000; n++ )
2015 {
2016 s << (wxChar)(wxT('A') + (n % 26));
2017 }
2018
2019 wxLogWarning(wxT("The length of the string is %lu"),
2020 (unsigned long)s.length());
2021
2022 wxString msg;
2023 msg.Printf(wxT("A very very long message: '%s', the end!\n"), s.c_str());
2024
2025 // this one shouldn't be truncated
2026 wxPrintf(msg);
2027
2028 // but this one will because log functions use fixed size buffer
2029 // (note that it doesn't need '\n' at the end neither - will be added
2030 // by wxLog anyhow)
2031 wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s.c_str());
2032 #endif // TEST_LOG
2033
2034 #ifdef TEST_FILE
2035 TestFileRead();
2036 TestTextFileRead();
2037 TestFileCopy();
2038 TestTempFile();
2039 #endif // TEST_FILE
2040
2041 #ifdef TEST_FILENAME
2042 TestFileNameTemp();
2043 TestFileNameCwd();
2044 TestFileNameDirManip();
2045 TestFileNameComparison();
2046 TestFileNameOperations();
2047 #endif // TEST_FILENAME
2048
2049 #ifdef TEST_FILETIME
2050 TestFileGetTimes();
2051 #if 0
2052 TestFileSetTimes();
2053 #endif
2054 #endif // TEST_FILETIME
2055
2056 #ifdef TEST_FTP
2057 wxLog::AddTraceMask(FTP_TRACE_MASK);
2058
2059 // wxFTP cannot be a static variable as its ctor needs to access
2060 // wxWidgets internals after it has been initialized
2061 ftp = new wxFTP;
2062 ftp->SetLog(new wxProtocolLog(FTP_TRACE_MASK));
2063 if ( TestFtpConnect() )
2064 TestFtpInteractive();
2065 //else: connecting to the FTP server failed
2066
2067 delete ftp;
2068 #endif // TEST_FTP
2069
2070 #ifdef TEST_MIME
2071 //wxLog::AddTraceMask(wxT("mime"));
2072 TestMimeEnum();
2073 #if 0
2074 TestMimeOverride();
2075 TestMimeAssociate();
2076 #endif
2077 TestMimeFilename();
2078 #endif // TEST_MIME
2079
2080 #ifdef TEST_INFO_FUNCTIONS
2081 TestOsInfo();
2082 TestPlatformInfo();
2083 TestUserInfo();
2084
2085 #if TEST_INTERACTIVE
2086 TestDiskInfo();
2087 #endif
2088 #endif // TEST_INFO_FUNCTIONS
2089
2090 #ifdef TEST_PATHLIST
2091 TestPathList();
2092 #endif // TEST_PATHLIST
2093
2094 #ifdef TEST_PRINTF
2095 TestPrintf();
2096 #endif // TEST_PRINTF
2097
2098 #if defined TEST_REGEX && TEST_INTERACTIVE
2099 TestRegExInteractive();
2100 #endif // defined TEST_REGEX && TEST_INTERACTIVE
2101
2102 #ifdef TEST_DATETIME
2103 #if TEST_INTERACTIVE
2104 TestDateTimeInteractive();
2105 #endif
2106 #endif // TEST_DATETIME
2107
2108 #ifdef TEST_STACKWALKER
2109 #if wxUSE_STACKWALKER
2110 TestStackWalk(argv[0]);
2111 #endif
2112 #endif // TEST_STACKWALKER
2113
2114 #ifdef TEST_STDPATHS
2115 TestStandardPaths();
2116 #endif
2117
2118 #ifdef TEST_USLEEP
2119 wxPuts(wxT("Sleeping for 3 seconds... z-z-z-z-z..."));
2120 wxUsleep(3000);
2121 #endif // TEST_USLEEP
2122
2123 #ifdef TEST_VOLUME
2124 TestFSVolume();
2125 #endif // TEST_VOLUME
2126
2127 #if wxUSE_UNICODE
2128 {
2129 for ( int n = 0; n < argc; n++ )
2130 free(wxArgv[n]);
2131
2132 delete [] wxArgv;
2133 }
2134 #endif // wxUSE_UNICODE
2135
2136 wxUnusedVar(argc);
2137 wxUnusedVar(argv);
2138 return 0;
2139 }