remove test code for wxScopeGuard (there's already a better ScopeGuardTestCase)
[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 #define TEST_PRINTF
123 #define TEST_REGCONF
124 #define TEST_REGEX
125 #define TEST_REGISTRY
126 #else // #if TEST_ALL
127 #define TEST_DATETIME
128 #define TEST_VOLUME
129 #define TEST_STDPATHS
130 #define TEST_STACKWALKER
131 #define TEST_FTP
132 #define TEST_SNGLINST
133 #endif
134
135 // some tests are interactive, define this to run them
136 #ifdef TEST_INTERACTIVE
137 #undef TEST_INTERACTIVE
138
139 #define TEST_INTERACTIVE 1
140 #else
141 #define TEST_INTERACTIVE 1
142 #endif
143
144 // ============================================================================
145 // implementation
146 // ============================================================================
147
148 // ----------------------------------------------------------------------------
149 // wxDir
150 // ----------------------------------------------------------------------------
151
152 #ifdef TEST_DIR
153
154 #include "wx/dir.h"
155
156 #ifdef __UNIX__
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:\\");
162 #else
163 #error "don't know where the root directory is"
164 #endif
165
166 static void TestDirEnumHelper(wxDir& dir,
167 int flags = wxDIR_DEFAULT,
168 const wxString& filespec = wxEmptyString)
169 {
170 wxString filename;
171
172 if ( !dir.IsOpened() )
173 return;
174
175 bool cont = dir.GetFirst(&filename, filespec, flags);
176 while ( cont )
177 {
178 wxPrintf(wxT("\t%s\n"), filename.c_str());
179
180 cont = dir.GetNext(&filename);
181 }
182
183 wxPuts(wxEmptyString);
184 }
185
186 #if TEST_ALL
187
188 static void TestDirEnum()
189 {
190 wxPuts(wxT("*** Testing wxDir::GetFirst/GetNext ***"));
191
192 wxString cwd = wxGetCwd();
193 if ( !wxDir::Exists(cwd) )
194 {
195 wxPrintf(wxT("ERROR: current directory '%s' doesn't exist?\n"), cwd.c_str());
196 return;
197 }
198
199 wxDir dir(cwd);
200 if ( !dir.IsOpened() )
201 {
202 wxPrintf(wxT("ERROR: failed to open current directory '%s'.\n"), cwd.c_str());
203 return;
204 }
205
206 wxPuts(wxT("Enumerating everything in current directory:"));
207 TestDirEnumHelper(dir);
208
209 wxPuts(wxT("Enumerating really everything in current directory:"));
210 TestDirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT);
211
212 wxPuts(wxT("Enumerating object files in current directory:"));
213 TestDirEnumHelper(dir, wxDIR_DEFAULT, wxT("*.o*"));
214
215 wxPuts(wxT("Enumerating directories in current directory:"));
216 TestDirEnumHelper(dir, wxDIR_DIRS);
217
218 wxPuts(wxT("Enumerating files in current directory:"));
219 TestDirEnumHelper(dir, wxDIR_FILES);
220
221 wxPuts(wxT("Enumerating files including hidden in current directory:"));
222 TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
223
224 dir.Open(ROOTDIR);
225
226 wxPuts(wxT("Enumerating everything in root directory:"));
227 TestDirEnumHelper(dir, wxDIR_DEFAULT);
228
229 wxPuts(wxT("Enumerating directories in root directory:"));
230 TestDirEnumHelper(dir, wxDIR_DIRS);
231
232 wxPuts(wxT("Enumerating files in root directory:"));
233 TestDirEnumHelper(dir, wxDIR_FILES);
234
235 wxPuts(wxT("Enumerating files including hidden in root directory:"));
236 TestDirEnumHelper(dir, wxDIR_FILES | wxDIR_HIDDEN);
237
238 wxPuts(wxT("Enumerating files in non existing directory:"));
239 wxDir dirNo(wxT("nosuchdir"));
240 TestDirEnumHelper(dirNo);
241 }
242
243 #endif // TEST_ALL
244
245 class DirPrintTraverser : public wxDirTraverser
246 {
247 public:
248 virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
249 {
250 return wxDIR_CONTINUE;
251 }
252
253 virtual wxDirTraverseResult OnDir(const wxString& dirname)
254 {
255 wxString path, name, ext;
256 wxFileName::SplitPath(dirname, &path, &name, &ext);
257
258 if ( !ext.empty() )
259 name << wxT('.') << ext;
260
261 wxString indent;
262 for ( const wxChar *p = path.c_str(); *p; p++ )
263 {
264 if ( wxIsPathSeparator(*p) )
265 indent += wxT(" ");
266 }
267
268 wxPrintf(wxT("%s%s\n"), indent.c_str(), name.c_str());
269
270 return wxDIR_CONTINUE;
271 }
272 };
273
274 static void TestDirTraverse()
275 {
276 wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
277
278 // enum all files
279 wxArrayString files;
280 size_t n = wxDir::GetAllFiles(TESTDIR, &files);
281 wxPrintf(wxT("There are %u files under '%s'\n"), n, TESTDIR);
282 if ( n > 1 )
283 {
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());
286 }
287
288 // enum again with custom traverser
289 wxPuts(wxT("Now enumerating directories:"));
290 wxDir dir(TESTDIR);
291 DirPrintTraverser traverser;
292 dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN);
293 }
294
295 #if TEST_ALL
296
297 static void TestDirExists()
298 {
299 wxPuts(wxT("*** Testing wxDir::Exists() ***"));
300
301 static const wxChar *dirnames[] =
302 {
303 wxT("."),
304 #if defined(__WXMSW__)
305 wxT("c:"),
306 wxT("c:\\"),
307 wxT("\\\\share\\file"),
308 wxT("c:\\dos"),
309 wxT("c:\\dos\\"),
310 wxT("c:\\dos\\\\"),
311 wxT("c:\\autoexec.bat"),
312 #elif defined(__UNIX__)
313 wxT("/"),
314 wxT("//"),
315 wxT("/usr/bin"),
316 wxT("/usr//bin"),
317 wxT("/usr///bin"),
318 #endif
319 };
320
321 for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
322 {
323 wxPrintf(wxT("%-40s: %s\n"),
324 dirnames[n],
325 wxDir::Exists(dirnames[n]) ? wxT("exists")
326 : wxT("doesn't exist"));
327 }
328 }
329
330 #endif // TEST_ALL
331
332 #endif // TEST_DIR
333
334 // ----------------------------------------------------------------------------
335 // wxDllLoader
336 // ----------------------------------------------------------------------------
337
338 #ifdef TEST_DYNLIB
339
340 #include "wx/dynlib.h"
341
342 static void TestDllLoad()
343 {
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");
351 #else
352 #error "don't know how to test wxDllLoader on this platform"
353 #endif
354
355 wxPuts(wxT("*** testing basic wxDynamicLibrary functions ***\n"));
356
357 wxDynamicLibrary lib(LIB_NAME);
358 if ( !lib.IsLoaded() )
359 {
360 wxPrintf(wxT("ERROR: failed to load '%s'.\n"), LIB_NAME);
361 }
362 else
363 {
364 typedef int (wxSTDCALL *wxStrlenType)(const char *);
365 wxStrlenType pfnStrlen = (wxStrlenType)lib.GetSymbol(FUNC_NAME);
366 if ( !pfnStrlen )
367 {
368 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
369 FUNC_NAME, LIB_NAME);
370 }
371 else
372 {
373 wxPrintf(wxT("Calling %s dynamically loaded from %s "),
374 FUNC_NAME, LIB_NAME);
375
376 if ( pfnStrlen("foo") != 3 )
377 {
378 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
379 }
380 else
381 {
382 wxPuts(wxT("... ok"));
383 }
384 }
385
386 #ifdef __WXMSW__
387 static const wxChar *FUNC_NAME_AW = wxT("lstrlen");
388
389 typedef int (wxSTDCALL *wxStrlenTypeAorW)(const wxChar *);
390 wxStrlenTypeAorW
391 pfnStrlenAorW = (wxStrlenTypeAorW)lib.GetSymbolAorW(FUNC_NAME_AW);
392 if ( !pfnStrlenAorW )
393 {
394 wxPrintf(wxT("ERROR: function '%s' wasn't found in '%s'.\n"),
395 FUNC_NAME_AW, LIB_NAME);
396 }
397 else
398 {
399 if ( pfnStrlenAorW(wxT("foobar")) != 6 )
400 {
401 wxPrintf(wxT("ERROR: loaded function is not wxStrlen()!\n"));
402 }
403 }
404 #endif // __WXMSW__
405 }
406 }
407
408 #if defined(__WXMSW__) || defined(__UNIX__)
409
410 static void TestDllListLoaded()
411 {
412 wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
413
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 )
418 {
419 const wxDynamicLibraryDetails& details = dlls[n];
420 printf("%-45s", (const char *)details.GetPath().mb_str());
421
422 void *addr wxDUMMY_INITIALIZE(NULL);
423 size_t len wxDUMMY_INITIALIZE(0);
424 if ( details.GetAddress(&addr, &len) )
425 {
426 printf(" %08lx:%08lx",
427 (unsigned long)addr, (unsigned long)((char *)addr + len));
428 }
429
430 printf(" %s\n", (const char *)details.GetVersion().mb_str());
431 }
432 }
433
434 #endif
435
436 #endif // TEST_DYNLIB
437
438 // ----------------------------------------------------------------------------
439 // wxGet/SetEnv
440 // ----------------------------------------------------------------------------
441
442 #ifdef TEST_ENVIRON
443
444 #include "wx/utils.h"
445
446 static wxString MyGetEnv(const wxString& var)
447 {
448 wxString val;
449 if ( !wxGetEnv(var, &val) )
450 val = wxT("<empty>");
451 else
452 val = wxString(wxT('\'')) + val + wxT('\'');
453
454 return val;
455 }
456
457 static void TestEnvironment()
458 {
459 const wxChar *var = wxT("wxTestVar");
460
461 wxPuts(wxT("*** testing environment access functions ***"));
462
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());
468 wxUnsetEnv(var);
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());
471 }
472
473 #endif // TEST_ENVIRON
474
475 // ----------------------------------------------------------------------------
476 // file
477 // ----------------------------------------------------------------------------
478
479 #ifdef TEST_FILE
480
481 #include "wx/file.h"
482 #include "wx/ffile.h"
483 #include "wx/textfile.h"
484
485 static void TestFileRead()
486 {
487 wxPuts(wxT("*** wxFile read test ***"));
488
489 wxFile file(wxT("testdata.fc"));
490 if ( file.IsOpened() )
491 {
492 wxPrintf(wxT("File length: %lu\n"), file.Length());
493
494 wxPuts(wxT("File dump:\n----------"));
495
496 static const size_t len = 1024;
497 wxChar buf[len];
498 for ( ;; )
499 {
500 size_t nRead = file.Read(buf, len);
501 if ( nRead == (size_t)wxInvalidOffset )
502 {
503 wxPrintf(wxT("Failed to read the file."));
504 break;
505 }
506
507 fwrite(buf, nRead, 1, stdout);
508
509 if ( nRead < len )
510 break;
511 }
512
513 wxPuts(wxT("----------"));
514 }
515 else
516 {
517 wxPrintf(wxT("ERROR: can't open test file.\n"));
518 }
519
520 wxPuts(wxEmptyString);
521 }
522
523 static void TestTextFileRead()
524 {
525 wxPuts(wxT("*** wxTextFile read test ***"));
526
527 wxTextFile file(wxT("testdata.fc"));
528 if ( file.Open() )
529 {
530 wxPrintf(wxT("Number of lines: %u\n"), file.GetLineCount());
531 wxPrintf(wxT("Last line: '%s'\n"), file.GetLastLine().c_str());
532
533 wxString s;
534
535 wxPuts(wxT("\nDumping the entire file:"));
536 for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
537 {
538 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
539 }
540 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
541
542 wxPuts(wxT("\nAnd now backwards:"));
543 for ( s = file.GetLastLine();
544 file.GetCurrentLine() != 0;
545 s = file.GetPrevLine() )
546 {
547 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
548 }
549 wxPrintf(wxT("%6u: %s\n"), file.GetCurrentLine() + 1, s.c_str());
550 }
551 else
552 {
553 wxPrintf(wxT("ERROR: can't open '%s'\n"), file.GetName());
554 }
555
556 wxPuts(wxEmptyString);
557 }
558
559 static void TestFileCopy()
560 {
561 wxPuts(wxT("*** Testing wxCopyFile ***"));
562
563 static const wxChar *filename1 = wxT("testdata.fc");
564 static const wxChar *filename2 = wxT("test2");
565 if ( !wxCopyFile(filename1, filename2) )
566 {
567 wxPuts(wxT("ERROR: failed to copy file"));
568 }
569 else
570 {
571 wxFFile f1(filename1, wxT("rb")),
572 f2(filename2, wxT("rb"));
573
574 if ( !f1.IsOpened() || !f2.IsOpened() )
575 {
576 wxPuts(wxT("ERROR: failed to open file(s)"));
577 }
578 else
579 {
580 wxString s1, s2;
581 if ( !f1.ReadAll(&s1) || !f2.ReadAll(&s2) )
582 {
583 wxPuts(wxT("ERROR: failed to read file(s)"));
584 }
585 else
586 {
587 if ( (s1.length() != s2.length()) ||
588 (memcmp(s1.c_str(), s2.c_str(), s1.length()) != 0) )
589 {
590 wxPuts(wxT("ERROR: copy error!"));
591 }
592 else
593 {
594 wxPuts(wxT("File was copied ok."));
595 }
596 }
597 }
598 }
599
600 if ( !wxRemoveFile(filename2) )
601 {
602 wxPuts(wxT("ERROR: failed to remove the file"));
603 }
604
605 wxPuts(wxEmptyString);
606 }
607
608 static void TestTempFile()
609 {
610 wxPuts(wxT("*** wxTempFile test ***"));
611
612 wxTempFile tmpFile;
613 if ( tmpFile.Open(wxT("test2")) && tmpFile.Write(wxT("the answer is 42")) )
614 {
615 if ( tmpFile.Commit() )
616 wxPuts(wxT("File committed."));
617 else
618 wxPuts(wxT("ERROR: could't commit temp file."));
619
620 wxRemoveFile(wxT("test2"));
621 }
622
623 wxPuts(wxEmptyString);
624 }
625
626 #endif // TEST_FILE
627
628 // ----------------------------------------------------------------------------
629 // wxFileConfig
630 // ----------------------------------------------------------------------------
631
632 #ifdef TEST_FILECONF
633
634 #include "wx/confbase.h"
635 #include "wx/fileconf.h"
636
637 static const struct FileConfTestData
638 {
639 const wxChar *name; // value name
640 const wxChar *value; // the value from the file
641 } fcTestData[] =
642 {
643 { wxT("value1"), wxT("one") },
644 { wxT("value2"), wxT("two") },
645 { wxT("novalue"), wxT("default") },
646 };
647
648 static void TestFileConfRead()
649 {
650 wxPuts(wxT("*** testing wxFileConfig loading/reading ***"));
651
652 wxFileConfig fileconf(wxT("test"), wxEmptyString,
653 wxT("testdata.fc"), wxEmptyString,
654 wxCONFIG_USE_RELATIVE_PATH);
655
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++ )
660 {
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 )
665 {
666 wxPuts(wxT("(ok)"));
667 }
668 else
669 {
670 wxPrintf(wxT("(ERROR: should be %s)\n"), data.value);
671 }
672 }
673
674 // test enumerating the entries
675 wxPuts(wxT("\nEnumerating all root entries:"));
676 long dummy;
677 wxString name;
678 bool cont = fileconf.GetFirstEntry(name, dummy);
679 while ( cont )
680 {
681 wxPrintf(wxT("\t%s = %s\n"),
682 name.c_str(),
683 fileconf.Read(name.c_str(), wxT("ERROR")).c_str());
684
685 cont = fileconf.GetNextEntry(name, dummy);
686 }
687
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"));
693 }
694
695 #endif // TEST_FILECONF
696
697 // ----------------------------------------------------------------------------
698 // wxFileName
699 // ----------------------------------------------------------------------------
700
701 #ifdef TEST_FILENAME
702
703 #include "wx/filename.h"
704
705 #if 0
706 static void DumpFileName(const wxChar *desc, const wxFileName& fn)
707 {
708 wxPuts(desc);
709
710 wxString full = fn.GetFullPath();
711
712 wxString vol, path, name, ext;
713 wxFileName::SplitPath(full, &vol, &path, &name, &ext);
714
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());
717
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());
721
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());
729
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++ )
734 {
735 wxPrintf(wxT("\t%u: %s\n"), n, dirs[n].c_str());
736 }
737 }
738 #endif
739
740 static void TestFileNameTemp()
741 {
742 wxPuts(wxT("*** testing wxFileName temp file creation ***"));
743
744 static const wxChar *tmpprefixes[] =
745 {
746 wxT(""),
747 wxT("foo"),
748 wxT(".."),
749 wxT("../bar"),
750 #ifdef __UNIX__
751 wxT("/tmp/foo"),
752 wxT("/tmp/foo/bar"), // this one must be an error
753 #endif // __UNIX__
754 };
755
756 for ( size_t n = 0; n < WXSIZEOF(tmpprefixes); n++ )
757 {
758 wxString path = wxFileName::CreateTempFileName(tmpprefixes[n]);
759 if ( path.empty() )
760 {
761 // "error" is not in upper case because it may be ok
762 wxPrintf(wxT("Prefix '%s'\t-> error\n"), tmpprefixes[n]);
763 }
764 else
765 {
766 wxPrintf(wxT("Prefix '%s'\t-> temp file '%s'\n"),
767 tmpprefixes[n], path.c_str());
768
769 if ( !wxRemoveFile(path) )
770 {
771 wxLogWarning(wxT("Failed to remove temp file '%s'"),
772 path.c_str());
773 }
774 }
775 }
776 }
777
778 static void TestFileNameDirManip()
779 {
780 // TODO: test AppendDir(), RemoveDir(), ...
781 }
782
783 static void TestFileNameComparison()
784 {
785 // TODO!
786 }
787
788 static void TestFileNameOperations()
789 {
790 // TODO!
791 }
792
793 static void TestFileNameCwd()
794 {
795 // TODO!
796 }
797
798 #endif // TEST_FILENAME
799
800 // ----------------------------------------------------------------------------
801 // wxFileName time functions
802 // ----------------------------------------------------------------------------
803
804 #ifdef TEST_FILETIME
805
806 #include "wx/filename.h"
807 #include "wx/datetime.h"
808
809 static void TestFileGetTimes()
810 {
811 wxFileName fn(wxT("testdata.fc"));
812
813 wxDateTime dtAccess, dtMod, dtCreate;
814 if ( !fn.GetTimes(&dtAccess, &dtMod, &dtCreate) )
815 {
816 wxPrintf(wxT("ERROR: GetTimes() failed.\n"));
817 }
818 else
819 {
820 static const wxChar *fmt = wxT("%Y-%b-%d %H:%M:%S");
821
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());
826 }
827 }
828
829 #if 0
830 static void TestFileSetTimes()
831 {
832 wxFileName fn(wxT("testdata.fc"));
833
834 if ( !fn.Touch() )
835 {
836 wxPrintf(wxT("ERROR: Touch() failed.\n"));
837 }
838 }
839 #endif
840
841 #endif // TEST_FILETIME
842
843 // ----------------------------------------------------------------------------
844 // wxLocale
845 // ----------------------------------------------------------------------------
846
847 #ifdef TEST_LOCALE
848
849 #include "wx/intl.h"
850 #include "wx/utils.h" // for wxSetEnv
851
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()
856
857 // find the name of the language from its value
858 static const wxChar *GetLangName(int lang)
859 {
860 static const wxChar *languageNames[] =
861 {
862 wxT("DEFAULT"),
863 wxT("UNKNOWN"),
864 wxT("ABKHAZIAN"),
865 wxT("AFAR"),
866 wxT("AFRIKAANS"),
867 wxT("ALBANIAN"),
868 wxT("AMHARIC"),
869 wxT("ARABIC"),
870 wxT("ARABIC_ALGERIA"),
871 wxT("ARABIC_BAHRAIN"),
872 wxT("ARABIC_EGYPT"),
873 wxT("ARABIC_IRAQ"),
874 wxT("ARABIC_JORDAN"),
875 wxT("ARABIC_KUWAIT"),
876 wxT("ARABIC_LEBANON"),
877 wxT("ARABIC_LIBYA"),
878 wxT("ARABIC_MOROCCO"),
879 wxT("ARABIC_OMAN"),
880 wxT("ARABIC_QATAR"),
881 wxT("ARABIC_SAUDI_ARABIA"),
882 wxT("ARABIC_SUDAN"),
883 wxT("ARABIC_SYRIA"),
884 wxT("ARABIC_TUNISIA"),
885 wxT("ARABIC_UAE"),
886 wxT("ARABIC_YEMEN"),
887 wxT("ARMENIAN"),
888 wxT("ASSAMESE"),
889 wxT("AYMARA"),
890 wxT("AZERI"),
891 wxT("AZERI_CYRILLIC"),
892 wxT("AZERI_LATIN"),
893 wxT("BASHKIR"),
894 wxT("BASQUE"),
895 wxT("BELARUSIAN"),
896 wxT("BENGALI"),
897 wxT("BHUTANI"),
898 wxT("BIHARI"),
899 wxT("BISLAMA"),
900 wxT("BRETON"),
901 wxT("BULGARIAN"),
902 wxT("BURMESE"),
903 wxT("CAMBODIAN"),
904 wxT("CATALAN"),
905 wxT("CHINESE"),
906 wxT("CHINESE_SIMPLIFIED"),
907 wxT("CHINESE_TRADITIONAL"),
908 wxT("CHINESE_HONGKONG"),
909 wxT("CHINESE_MACAU"),
910 wxT("CHINESE_SINGAPORE"),
911 wxT("CHINESE_TAIWAN"),
912 wxT("CORSICAN"),
913 wxT("CROATIAN"),
914 wxT("CZECH"),
915 wxT("DANISH"),
916 wxT("DUTCH"),
917 wxT("DUTCH_BELGIAN"),
918 wxT("ENGLISH"),
919 wxT("ENGLISH_UK"),
920 wxT("ENGLISH_US"),
921 wxT("ENGLISH_AUSTRALIA"),
922 wxT("ENGLISH_BELIZE"),
923 wxT("ENGLISH_BOTSWANA"),
924 wxT("ENGLISH_CANADA"),
925 wxT("ENGLISH_CARIBBEAN"),
926 wxT("ENGLISH_DENMARK"),
927 wxT("ENGLISH_EIRE"),
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"),
934 wxT("ESPERANTO"),
935 wxT("ESTONIAN"),
936 wxT("FAEROESE"),
937 wxT("FARSI"),
938 wxT("FIJI"),
939 wxT("FINNISH"),
940 wxT("FRENCH"),
941 wxT("FRENCH_BELGIAN"),
942 wxT("FRENCH_CANADIAN"),
943 wxT("FRENCH_LUXEMBOURG"),
944 wxT("FRENCH_MONACO"),
945 wxT("FRENCH_SWISS"),
946 wxT("FRISIAN"),
947 wxT("GALICIAN"),
948 wxT("GEORGIAN"),
949 wxT("GERMAN"),
950 wxT("GERMAN_AUSTRIAN"),
951 wxT("GERMAN_BELGIUM"),
952 wxT("GERMAN_LIECHTENSTEIN"),
953 wxT("GERMAN_LUXEMBOURG"),
954 wxT("GERMAN_SWISS"),
955 wxT("GREEK"),
956 wxT("GREENLANDIC"),
957 wxT("GUARANI"),
958 wxT("GUJARATI"),
959 wxT("HAUSA"),
960 wxT("HEBREW"),
961 wxT("HINDI"),
962 wxT("HUNGARIAN"),
963 wxT("ICELANDIC"),
964 wxT("INDONESIAN"),
965 wxT("INTERLINGUA"),
966 wxT("INTERLINGUE"),
967 wxT("INUKTITUT"),
968 wxT("INUPIAK"),
969 wxT("IRISH"),
970 wxT("ITALIAN"),
971 wxT("ITALIAN_SWISS"),
972 wxT("JAPANESE"),
973 wxT("JAVANESE"),
974 wxT("KANNADA"),
975 wxT("KASHMIRI"),
976 wxT("KASHMIRI_INDIA"),
977 wxT("KAZAKH"),
978 wxT("KERNEWEK"),
979 wxT("KINYARWANDA"),
980 wxT("KIRGHIZ"),
981 wxT("KIRUNDI"),
982 wxT("KONKANI"),
983 wxT("KOREAN"),
984 wxT("KURDISH"),
985 wxT("LAOTHIAN"),
986 wxT("LATIN"),
987 wxT("LATVIAN"),
988 wxT("LINGALA"),
989 wxT("LITHUANIAN"),
990 wxT("MACEDONIAN"),
991 wxT("MALAGASY"),
992 wxT("MALAY"),
993 wxT("MALAYALAM"),
994 wxT("MALAY_BRUNEI_DARUSSALAM"),
995 wxT("MALAY_MALAYSIA"),
996 wxT("MALTESE"),
997 wxT("MANIPURI"),
998 wxT("MAORI"),
999 wxT("MARATHI"),
1000 wxT("MOLDAVIAN"),
1001 wxT("MONGOLIAN"),
1002 wxT("NAURU"),
1003 wxT("NEPALI"),
1004 wxT("NEPALI_INDIA"),
1005 wxT("NORWEGIAN_BOKMAL"),
1006 wxT("NORWEGIAN_NYNORSK"),
1007 wxT("OCCITAN"),
1008 wxT("ORIYA"),
1009 wxT("OROMO"),
1010 wxT("PASHTO"),
1011 wxT("POLISH"),
1012 wxT("PORTUGUESE"),
1013 wxT("PORTUGUESE_BRAZILIAN"),
1014 wxT("PUNJABI"),
1015 wxT("QUECHUA"),
1016 wxT("RHAETO_ROMANCE"),
1017 wxT("ROMANIAN"),
1018 wxT("RUSSIAN"),
1019 wxT("RUSSIAN_UKRAINE"),
1020 wxT("SAMOAN"),
1021 wxT("SANGHO"),
1022 wxT("SANSKRIT"),
1023 wxT("SCOTS_GAELIC"),
1024 wxT("SERBIAN"),
1025 wxT("SERBIAN_CYRILLIC"),
1026 wxT("SERBIAN_LATIN"),
1027 wxT("SERBO_CROATIAN"),
1028 wxT("SESOTHO"),
1029 wxT("SETSWANA"),
1030 wxT("SHONA"),
1031 wxT("SINDHI"),
1032 wxT("SINHALESE"),
1033 wxT("SISWATI"),
1034 wxT("SLOVAK"),
1035 wxT("SLOVENIAN"),
1036 wxT("SOMALI"),
1037 wxT("SPANISH"),
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"),
1056 wxT("SPANISH_US"),
1057 wxT("SPANISH_VENEZUELA"),
1058 wxT("SUNDANESE"),
1059 wxT("SWAHILI"),
1060 wxT("SWEDISH"),
1061 wxT("SWEDISH_FINLAND"),
1062 wxT("TAGALOG"),
1063 wxT("TAJIK"),
1064 wxT("TAMIL"),
1065 wxT("TATAR"),
1066 wxT("TELUGU"),
1067 wxT("THAI"),
1068 wxT("TIBETAN"),
1069 wxT("TIGRINYA"),
1070 wxT("TONGA"),
1071 wxT("TSONGA"),
1072 wxT("TURKISH"),
1073 wxT("TURKMEN"),
1074 wxT("TWI"),
1075 wxT("UIGHUR"),
1076 wxT("UKRAINIAN"),
1077 wxT("URDU"),
1078 wxT("URDU_INDIA"),
1079 wxT("URDU_PAKISTAN"),
1080 wxT("UZBEK"),
1081 wxT("UZBEK_CYRILLIC"),
1082 wxT("UZBEK_LATIN"),
1083 wxT("VIETNAMESE"),
1084 wxT("VOLAPUK"),
1085 wxT("WELSH"),
1086 wxT("WOLOF"),
1087 wxT("XHOSA"),
1088 wxT("YIDDISH"),
1089 wxT("YORUBA"),
1090 wxT("ZHUANG"),
1091 wxT("ZULU"),
1092 };
1093
1094 if ( (size_t)lang < WXSIZEOF(languageNames) )
1095 return languageNames[lang];
1096 else
1097 return wxT("INVALID");
1098 }
1099
1100 static void TestDefaultLang()
1101 {
1102 wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
1103
1104 gs_localeDefault.Init(wxLANGUAGE_ENGLISH);
1105
1106 static const wxChar *langStrings[] =
1107 {
1108 NULL, // system default
1109 wxT("C"),
1110 wxT("fr"),
1111 wxT("fr_FR"),
1112 wxT("en"),
1113 wxT("en_GB"),
1114 wxT("en_US"),
1115 wxT("de_DE.iso88591"),
1116 wxT("german"),
1117 wxT("?"), // invalid lang spec
1118 wxT("klingonese"), // I bet on some systems it does exist...
1119 };
1120
1121 wxPrintf(wxT("The default system encoding is %s (%d)\n"),
1122 wxLocale::GetSystemEncodingName().c_str(),
1123 wxLocale::GetSystemEncoding());
1124
1125 for ( size_t n = 0; n < WXSIZEOF(langStrings); n++ )
1126 {
1127 const wxChar *langStr = langStrings[n];
1128 if ( langStr )
1129 {
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);
1133 }
1134
1135 int lang = gs_localeDefault.GetSystemLanguage();
1136 wxPrintf(wxT("Locale for '%s' is %s.\n"),
1137 langStr ? langStr : wxT("system default"), GetLangName(lang));
1138 }
1139 }
1140
1141 #endif // TEST_LOCALE
1142
1143 // ----------------------------------------------------------------------------
1144 // MIME types
1145 // ----------------------------------------------------------------------------
1146
1147 #ifdef TEST_MIME
1148
1149 #include "wx/mimetype.h"
1150
1151 static void TestMimeEnum()
1152 {
1153 wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
1154
1155 wxArrayString mimetypes;
1156
1157 size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
1158
1159 wxPrintf(wxT("*** All %u known filetypes: ***\n"), count);
1160
1161 wxArrayString exts;
1162 wxString desc;
1163
1164 for ( size_t n = 0; n < count; n++ )
1165 {
1166 wxFileType *filetype =
1167 wxTheMimeTypesManager->GetFileTypeFromMimeType(mimetypes[n]);
1168 if ( !filetype )
1169 {
1170 wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
1171 mimetypes[n].c_str());
1172 continue;
1173 }
1174
1175 filetype->GetDescription(&desc);
1176 filetype->GetExtensions(exts);
1177
1178 filetype->GetIcon(NULL);
1179
1180 wxString extsAll;
1181 for ( size_t e = 0; e < exts.GetCount(); e++ )
1182 {
1183 if ( e > 0 )
1184 extsAll << wxT(", ");
1185 extsAll += exts[e];
1186 }
1187
1188 wxPrintf(wxT("\t%s: %s (%s)\n"),
1189 mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
1190 }
1191
1192 wxPuts(wxEmptyString);
1193 }
1194
1195 static void TestMimeFilename()
1196 {
1197 wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
1198
1199 static const wxChar *filenames[] =
1200 {
1201 wxT("readme.txt"),
1202 wxT("document.pdf"),
1203 wxT("image.gif"),
1204 wxT("picture.jpeg"),
1205 };
1206
1207 for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
1208 {
1209 const wxString fname = filenames[n];
1210 wxString ext = fname.AfterLast(wxT('.'));
1211 wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
1212 if ( !ft )
1213 {
1214 wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext.c_str());
1215 }
1216 else
1217 {
1218 wxString desc;
1219 if ( !ft->GetDescription(&desc) )
1220 desc = wxT("<no description>");
1221
1222 wxString cmd;
1223 if ( !ft->GetOpenCommand(&cmd,
1224 wxFileType::MessageParameters(fname, wxEmptyString)) )
1225 cmd = wxT("<no command available>");
1226 else
1227 cmd = wxString(wxT('"')) + cmd + wxT('"');
1228
1229 wxPrintf(wxT("To open %s (%s) do %s.\n"),
1230 fname.c_str(), desc.c_str(), cmd.c_str());
1231
1232 delete ft;
1233 }
1234 }
1235
1236 wxPuts(wxEmptyString);
1237 }
1238
1239 // these tests were broken by wxMimeTypesManager changes, temporarily disabling
1240 #if 0
1241
1242 static void TestMimeOverride()
1243 {
1244 wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
1245
1246 static const wxChar *mailcap = wxT("/tmp/mailcap");
1247 static const wxChar *mimetypes = wxT("/tmp/mime.types");
1248
1249 if ( wxFile::Exists(mailcap) )
1250 wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
1251 mailcap,
1252 wxTheMimeTypesManager->ReadMailcap(mailcap) ? wxT("ok") : wxT("ERROR"));
1253 else
1254 wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
1255 mailcap);
1256
1257 if ( wxFile::Exists(mimetypes) )
1258 wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
1259 mimetypes,
1260 wxTheMimeTypesManager->ReadMimeTypes(mimetypes) ? wxT("ok") : wxT("ERROR"));
1261 else
1262 wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
1263 mimetypes);
1264
1265 wxPuts(wxEmptyString);
1266 }
1267
1268 static void TestMimeAssociate()
1269 {
1270 wxPuts(wxT("*** Testing creation of filetype association ***\n"));
1271
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
1279 );
1280 ftInfo.SetShortDesc(wxT("XYZFile")); // used under Win32 only
1281
1282 wxFileType *ft = wxTheMimeTypesManager->Associate(ftInfo);
1283 if ( !ft )
1284 {
1285 wxPuts(wxT("ERROR: failed to create association!"));
1286 }
1287 else
1288 {
1289 // TODO: read it back
1290 delete ft;
1291 }
1292
1293 wxPuts(wxEmptyString);
1294 }
1295
1296 #endif // 0
1297
1298 #endif // TEST_MIME
1299
1300 // ----------------------------------------------------------------------------
1301 // module dependencies feature
1302 // ----------------------------------------------------------------------------
1303
1304 #ifdef TEST_MODULE
1305
1306 #include "wx/module.h"
1307
1308 class wxTestModule : public wxModule
1309 {
1310 protected:
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()); }
1313 };
1314
1315 class wxTestModuleA : public wxTestModule
1316 {
1317 public:
1318 wxTestModuleA();
1319 private:
1320 DECLARE_DYNAMIC_CLASS(wxTestModuleA)
1321 };
1322
1323 class wxTestModuleB : public wxTestModule
1324 {
1325 public:
1326 wxTestModuleB();
1327 private:
1328 DECLARE_DYNAMIC_CLASS(wxTestModuleB)
1329 };
1330
1331 class wxTestModuleC : public wxTestModule
1332 {
1333 public:
1334 wxTestModuleC();
1335 private:
1336 DECLARE_DYNAMIC_CLASS(wxTestModuleC)
1337 };
1338
1339 class wxTestModuleD : public wxTestModule
1340 {
1341 public:
1342 wxTestModuleD();
1343 private:
1344 DECLARE_DYNAMIC_CLASS(wxTestModuleD)
1345 };
1346
1347 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC, wxModule)
1348 wxTestModuleC::wxTestModuleC()
1349 {
1350 AddDependency(CLASSINFO(wxTestModuleD));
1351 }
1352
1353 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA, wxModule)
1354 wxTestModuleA::wxTestModuleA()
1355 {
1356 AddDependency(CLASSINFO(wxTestModuleB));
1357 AddDependency(CLASSINFO(wxTestModuleD));
1358 }
1359
1360 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD, wxModule)
1361 wxTestModuleD::wxTestModuleD()
1362 {
1363 }
1364
1365 IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB, wxModule)
1366 wxTestModuleB::wxTestModuleB()
1367 {
1368 AddDependency(CLASSINFO(wxTestModuleD));
1369 AddDependency(CLASSINFO(wxTestModuleC));
1370 }
1371
1372 #endif // TEST_MODULE
1373
1374 // ----------------------------------------------------------------------------
1375 // misc information functions
1376 // ----------------------------------------------------------------------------
1377
1378 #ifdef TEST_INFO_FUNCTIONS
1379
1380 #include "wx/utils.h"
1381
1382 #if TEST_INTERACTIVE
1383 static void TestDiskInfo()
1384 {
1385 wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
1386
1387 for ( ;; )
1388 {
1389 wxChar pathname[128];
1390 wxPrintf(wxT("\nEnter a directory name: "));
1391 if ( !wxFgets(pathname, WXSIZEOF(pathname), stdin) )
1392 break;
1393
1394 // kill the last '\n'
1395 pathname[wxStrlen(pathname) - 1] = 0;
1396
1397 wxLongLong total, free;
1398 if ( !wxGetDiskSpace(pathname, &total, &free) )
1399 {
1400 wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
1401 }
1402 else
1403 {
1404 wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
1405 (total / 1024).ToString().c_str(),
1406 (free / 1024).ToString().c_str(),
1407 pathname);
1408 }
1409 }
1410 }
1411 #endif // TEST_INTERACTIVE
1412
1413 static void TestOsInfo()
1414 {
1415 wxPuts(wxT("*** Testing OS info functions ***\n"));
1416
1417 int major, minor;
1418 wxGetOsVersion(&major, &minor);
1419 wxPrintf(wxT("Running under: %s, version %d.%d\n"),
1420 wxGetOsDescription().c_str(), major, minor);
1421
1422 wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
1423
1424 wxPrintf(wxT("Host name is %s (%s).\n"),
1425 wxGetHostName().c_str(), wxGetFullHostName().c_str());
1426
1427 wxPuts(wxEmptyString);
1428 }
1429
1430 static void TestPlatformInfo()
1431 {
1432 wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
1433
1434 // get this platform
1435 wxPlatformInfo plat;
1436
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());
1443
1444 wxPuts(wxEmptyString);
1445 }
1446
1447 static void TestUserInfo()
1448 {
1449 wxPuts(wxT("*** Testing user info functions ***\n"));
1450
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());
1455
1456 wxPuts(wxEmptyString);
1457 }
1458
1459 #endif // TEST_INFO_FUNCTIONS
1460
1461 // ----------------------------------------------------------------------------
1462 // path list
1463 // ----------------------------------------------------------------------------
1464
1465 #ifdef TEST_PATHLIST
1466
1467 #ifdef __UNIX__
1468 #define CMD_IN_PATH wxT("ls")
1469 #else
1470 #define CMD_IN_PATH wxT("command.com")
1471 #endif
1472
1473 static void TestPathList()
1474 {
1475 wxPuts(wxT("*** Testing wxPathList ***\n"));
1476
1477 wxPathList pathlist;
1478 pathlist.AddEnvList(wxT("PATH"));
1479 wxString path = pathlist.FindValidPath(CMD_IN_PATH);
1480 if ( path.empty() )
1481 {
1482 wxPrintf(wxT("ERROR: command not found in the path.\n"));
1483 }
1484 else
1485 {
1486 wxPrintf(wxT("Command found in the path as '%s'.\n"), path.c_str());
1487 }
1488 }
1489
1490 #endif // TEST_PATHLIST
1491
1492 // ----------------------------------------------------------------------------
1493 // regular expressions
1494 // ----------------------------------------------------------------------------
1495
1496 #if defined TEST_REGEX && TEST_INTERACTIVE
1497
1498 #include "wx/regex.h"
1499
1500 static void TestRegExInteractive()
1501 {
1502 wxPuts(wxT("*** Testing RE interactively ***"));
1503
1504 for ( ;; )
1505 {
1506 wxChar pattern[128];
1507 wxPrintf(wxT("\nEnter a pattern: "));
1508 if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
1509 break;
1510
1511 // kill the last '\n'
1512 pattern[wxStrlen(pattern) - 1] = 0;
1513
1514 wxRegEx re;
1515 if ( !re.Compile(pattern) )
1516 {
1517 continue;
1518 }
1519
1520 wxChar text[128];
1521 for ( ;; )
1522 {
1523 wxPrintf(wxT("Enter text to match: "));
1524 if ( !wxFgets(text, WXSIZEOF(text), stdin) )
1525 break;
1526
1527 // kill the last '\n'
1528 text[wxStrlen(text) - 1] = 0;
1529
1530 if ( !re.Matches(text) )
1531 {
1532 wxPrintf(wxT("No match.\n"));
1533 }
1534 else
1535 {
1536 wxPrintf(wxT("Pattern matches at '%s'\n"), re.GetMatch(text).c_str());
1537
1538 size_t start, len;
1539 for ( size_t n = 1; ; n++ )
1540 {
1541 if ( !re.GetMatch(&start, &len, n) )
1542 {
1543 break;
1544 }
1545
1546 wxPrintf(wxT("Subexpr %u matched '%s'\n"),
1547 n, wxString(text + start, len).c_str());
1548 }
1549 }
1550 }
1551 }
1552 }
1553
1554 #endif // TEST_REGEX
1555
1556 // ----------------------------------------------------------------------------
1557 // printf() tests
1558 // ----------------------------------------------------------------------------
1559
1560 /*
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
1563 be a problem
1564 */
1565
1566 #ifdef TEST_PRINTF
1567
1568 #ifdef wxTEST_PRINTF
1569 // use our functions from wxchar.cpp
1570 #undef wxPrintf
1571 #undef wxSprintf
1572
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, ... );
1577 #endif
1578
1579 #include "wx/longlong.h"
1580
1581 #include <float.h>
1582
1583 static void rfg1 (void);
1584 static void rfg2 (void);
1585
1586
1587 static void
1588 fmtchk (const wxChar *fmt)
1589 {
1590 (void) wxPrintf(wxT("%s:\t`"), fmt);
1591 (void) wxPrintf(fmt, 0x12);
1592 (void) wxPrintf(wxT("'\n"));
1593 }
1594
1595 static void
1596 fmtst1chk (const wxChar *fmt)
1597 {
1598 (void) wxPrintf(wxT("%s:\t`"), fmt);
1599 (void) wxPrintf(fmt, 4, 0x12);
1600 (void) wxPrintf(wxT("'\n"));
1601 }
1602
1603 static void
1604 fmtst2chk (const wxChar *fmt)
1605 {
1606 (void) wxPrintf(wxT("%s:\t`"), fmt);
1607 (void) wxPrintf(fmt, 4, 4, 0x12);
1608 (void) wxPrintf(wxT("'\n"));
1609 }
1610
1611 /* This page is covered by the following copyright: */
1612
1613 /* (C) Copyright C E Chew
1614 *
1615 * Feel free to copy, use and distribute this software provided:
1616 *
1617 * 1. you do not pretend that you wrote it
1618 * 2. you leave this copyright notice intact.
1619 */
1620
1621 /*
1622 * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
1623 */
1624
1625 #define DEC -123
1626 #define INT 255
1627 #define UNS (~0)
1628
1629 /* Formatted Output Test
1630 *
1631 * This exercises the output formatting code.
1632 */
1633
1634 wxChar *PointerNull = NULL;
1635
1636 static void
1637 fp_test (void)
1638 {
1639 int i, j, k, l;
1640 wxChar buf[7];
1641 wxChar *prefix = buf;
1642 wxChar tp[20];
1643
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 |"));
1659 wxPrintf(tp, DEC);
1660 wxStrcpy(tp, prefix);
1661 wxStrcat(tp, wxT("6o |"));
1662 wxPrintf(tp, INT);
1663 wxStrcpy(tp, prefix);
1664 wxStrcat(tp, wxT("6x |"));
1665 wxPrintf(tp, INT);
1666 wxStrcpy(tp, prefix);
1667 wxStrcat(tp, wxT("6X |"));
1668 wxPrintf(tp, INT);
1669 wxStrcpy(tp, prefix);
1670 wxStrcat(tp, wxT("6u |"));
1671 wxPrintf(tp, UNS);
1672 wxPrintf(wxT("\n"));
1673 }
1674 }
1675 }
1676 }
1677 wxPrintf(wxT("%10s\n"), PointerNull);
1678 wxPrintf(wxT("%-10s\n"), PointerNull);
1679 }
1680
1681 static void TestPrintf()
1682 {
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.");
1686 int result = 0;
1687 wxString test_format;
1688
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"));
1695
1696 fmtst1chk(wxT("%.*x"));
1697 fmtst1chk(wxT("%0*x"));
1698 fmtst2chk(wxT("%*.*x"));
1699 fmtst2chk(wxT("%0*.*x"));
1700
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);
1704
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);
1716
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);
1725
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);
1738
1739 wxPrintf (wxT(" %6.5f\n"), .099999999860301614);
1740 wxPrintf (wxT(" %6.5f\n"), .1);
1741 wxPrintf (wxT("x%5.4fx\n"), .5);
1742
1743 wxPrintf (wxT("%#03x\n"), 1);
1744
1745 //wxPrintf (wxT("something really insane: %.10000f\n"), 1.0);
1746
1747 {
1748 double d = FLT_MIN;
1749 int niter = 17;
1750
1751 while (niter-- != 0)
1752 wxPrintf (wxT("%.17e\n"), d / 2);
1753 fflush (stdout);
1754 }
1755
1756 #ifndef __WATCOMC__
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);
1760 #endif
1761
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);
1772 #undef FORMAT
1773
1774 {
1775 wxChar buf[20];
1776 int rc = wxSnprintf (buf, WXSIZEOF(buf), wxT("%30s"), wxT("foo"));
1777
1778 wxPrintf(wxT("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
1779 rc, WXSIZEOF(buf), buf);
1780 #if 0
1781 wxChar buf2[512];
1782 wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
1783 wxSnprintf(buf2, WXSIZEOFbuf2), "%.999999u", 10));
1784 #endif
1785 }
1786
1787 fp_test ();
1788
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);
1796
1797 {
1798 double x=1.0;
1799 wxPrintf(wxT("%.17f\n"),(1.0/x/10.0+1.0)*x-x);
1800 }
1801
1802 {
1803 wxChar buf[200];
1804
1805 wxSprintf(buf,wxT("%*s%*s%*s"),-1,wxT("one"),-20,wxT("two"),-30,wxT("three"));
1806
1807 result |= wxStrcmp (buf,
1808 wxT("onetwo three "));
1809
1810 wxPuts (result != 0 ? wxT("Test failed!") : wxT("Test ok."));
1811 }
1812
1813 #ifdef wxLongLong_t
1814 {
1815 wxChar buf[200];
1816
1817 wxSprintf(buf, "%07" wxLongLongFmtSpec "o", wxLL(040000000000));
1818 #if 0
1819 // for some reason below line fails under Borland
1820 wxPrintf (wxT("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf);
1821 #endif
1822
1823 if (wxStrcmp (buf, wxT("40000000000")) != 0)
1824 {
1825 result = 1;
1826 wxPuts (wxT("\tFAILED"));
1827 }
1828 wxUnusedVar(result);
1829 wxPuts (wxEmptyString);
1830 }
1831 #endif // wxLongLong_t
1832
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);
1835
1836 wxPuts (wxT("--- Should be no further output. ---"));
1837 rfg1 ();
1838 rfg2 ();
1839
1840 #if 0
1841 {
1842 wxChar bytes[7];
1843 wxChar buf[20];
1844
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')
1849 {
1850 wxPuts (wxT("%hhn overwrite more bytes"));
1851 result = 1;
1852 }
1853 if (bytes[3] != 3)
1854 {
1855 wxPuts (wxT("%hhn wrote incorrect value"));
1856 result = 1;
1857 }
1858 }
1859 #endif
1860 }
1861
1862 static void
1863 rfg1 (void)
1864 {
1865 wxChar buf[100];
1866
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"));
1885 }
1886
1887 static void
1888 rfg2 (void)
1889 {
1890 int prec;
1891 wxChar buf[100];
1892 wxString test_format;
1893
1894 prec = 0;
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"));
1898 prec = 0;
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"));
1902 prec = 0;
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"));
1906 prec = 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"));
1911 prec = 7;
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"));
1916 prec = 3;
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"));
1921 prec = 3;
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"));
1926 }
1927
1928 #endif // TEST_PRINTF
1929
1930 // ----------------------------------------------------------------------------
1931 // registry and related stuff
1932 // ----------------------------------------------------------------------------
1933
1934 // this is for MSW only
1935 #ifndef __WXMSW__
1936 #undef TEST_REGCONF
1937 #undef TEST_REGISTRY
1938 #endif
1939
1940 #ifdef TEST_REGCONF
1941
1942 #include "wx/confbase.h"
1943 #include "wx/msw/regconf.h"
1944
1945 #if 0
1946 static void TestRegConfWrite()
1947 {
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"));
1953 }
1954 #endif
1955
1956 static void TestRegConfRead()
1957 {
1958 wxRegConfig *config = new wxRegConfig(wxT("myapp"));
1959
1960 wxString str;
1961 long dummy;
1962 config->SetPath(wxT("/"));
1963 wxPuts(wxT("Enumerating / subgroups:"));
1964 bool bCont = config->GetFirstGroup(str, dummy);
1965 while(bCont)
1966 {
1967 wxPuts(str);
1968 bCont = config->GetNextGroup(str, dummy);
1969 }
1970 }
1971
1972 #endif // TEST_REGCONF
1973
1974 #ifdef TEST_REGISTRY
1975
1976 #include "wx/msw/registry.h"
1977
1978 // I chose this one because I liked its name, but it probably only exists under
1979 // NT
1980 static const wxChar *TESTKEY =
1981 wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
1982
1983 static void TestRegistryRead()
1984 {
1985 wxPuts(wxT("*** testing registry reading ***"));
1986
1987 wxRegKey key(TESTKEY);
1988 wxPrintf(wxT("The test key name is '%s'.\n"), key.GetName().c_str());
1989 if ( !key.Open() )
1990 {
1991 wxPuts(wxT("ERROR: test key can't be opened, aborting test."));
1992
1993 return;
1994 }
1995
1996 size_t nSubKeys, nValues;
1997 if ( key.GetKeyInfo(&nSubKeys, NULL, &nValues, NULL) )
1998 {
1999 wxPrintf(wxT("It has %u subkeys and %u values.\n"), nSubKeys, nValues);
2000 }
2001
2002 wxPrintf(wxT("Enumerating values:\n"));
2003
2004 long dummy;
2005 wxString value;
2006 bool cont = key.GetFirstValue(value, dummy);
2007 while ( cont )
2008 {
2009 wxPrintf(wxT("Value '%s': type "), value.c_str());
2010 switch ( key.GetValueType(value) )
2011 {
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;
2019 }
2020
2021 wxPrintf(wxT(", value = "));
2022 if ( key.IsNumericValue(value) )
2023 {
2024 long val;
2025 key.QueryValue(value, &val);
2026 wxPrintf(wxT("%ld"), val);
2027 }
2028 else // string
2029 {
2030 wxString val;
2031 key.QueryValue(value, val);
2032 wxPrintf(wxT("'%s'"), val.c_str());
2033
2034 key.QueryRawValue(value, val);
2035 wxPrintf(wxT(" (raw value '%s')"), val.c_str());
2036 }
2037
2038 wxPutchar('\n');
2039
2040 cont = key.GetNextValue(value, dummy);
2041 }
2042 }
2043
2044 static void TestRegistryAssociation()
2045 {
2046 /*
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
2050 */
2051
2052 wxRegKey key;
2053
2054 key.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2055 key.Create();
2056 key = wxT("ddxf_auto_file") ;
2057 key.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2058 key.Create();
2059 key = wxT("ddxf_auto_file") ;
2060 key.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2061 key.Create();
2062 key = wxT("program,0") ;
2063 key.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2064 key.Create();
2065 key = wxT("program \"%1\"") ;
2066
2067 key.SetName(wxT("HKEY_CLASSES_ROOT\\.ddf") );
2068 key.DeleteSelf();
2069 key.SetName(wxT("HKEY_CLASSES_ROOT\\.flo") );
2070 key.DeleteSelf();
2071 key.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\DefaultIcon"));
2072 key.DeleteSelf();
2073 key.SetName(wxT("HKEY_CLASSES_ROOT\\ddxf_auto_file\\shell\\open\\command"));
2074 key.DeleteSelf();
2075 }
2076
2077 #endif // TEST_REGISTRY
2078
2079 // ----------------------------------------------------------------------------
2080 // FTP
2081 // ----------------------------------------------------------------------------
2082
2083 #ifdef TEST_FTP
2084
2085 #include "wx/protocol/ftp.h"
2086 #include "wx/protocol/log.h"
2087
2088 #define FTP_ANONYMOUS
2089
2090 static wxFTP *ftp;
2091
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");
2096 #else
2097 static const wxChar *hostname = "localhost";
2098 static const wxChar *directory = wxT("/etc");
2099 static const wxChar *filename = wxT("issue");
2100 #endif
2101
2102 static bool TestFtpConnect()
2103 {
2104 wxPuts(wxT("*** Testing FTP connect ***"));
2105
2106 #ifdef FTP_ANONYMOUS
2107 wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
2108 #else // !FTP_ANONYMOUS
2109 wxChar user[256];
2110 wxFgets(user, WXSIZEOF(user), stdin);
2111 user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
2112 ftp->SetUser(user);
2113
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);
2119
2120 wxPrintf(wxT("--- Attempting to connect to %s:21 as %s...\n"), hostname, user);
2121 #endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
2122
2123 if ( !ftp->Connect(hostname) )
2124 {
2125 wxPrintf(wxT("ERROR: failed to connect to %s\n"), hostname);
2126
2127 return false;
2128 }
2129 else
2130 {
2131 wxPrintf(wxT("--- Connected to %s, current directory is '%s'\n"),
2132 hostname, ftp->Pwd().c_str());
2133 ftp->Close();
2134 }
2135
2136 return true;
2137 }
2138
2139 #if TEST_INTERACTIVE
2140 static void TestFtpInteractive()
2141 {
2142 wxPuts(wxT("\n*** Interactive wxFTP test ***"));
2143
2144 wxChar buf[128];
2145
2146 for ( ;; )
2147 {
2148 wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
2149 if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
2150 break;
2151
2152 // kill the last '\n'
2153 buf[wxStrlen(buf) - 1] = 0;
2154
2155 // special handling of LIST and NLST as they require data connection
2156 wxString start(buf, 4);
2157 start.MakeUpper();
2158 if ( start == wxT("LIST") || start == wxT("NLST") )
2159 {
2160 wxString wildcard;
2161 if ( wxStrlen(buf) > 4 )
2162 wildcard = buf + 5;
2163
2164 wxArrayString files;
2165 if ( !ftp->GetList(files, wildcard, start == wxT("LIST")) )
2166 {
2167 wxPrintf(wxT("ERROR: failed to get %s of files\n"), start.c_str());
2168 }
2169 else
2170 {
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++ )
2175 {
2176 wxPrintf(wxT("\t%s\n"), files[n].c_str());
2177 }
2178 wxPuts(wxT("--- End of the file list"));
2179 }
2180 }
2181 else if ( start == wxT("QUIT") )
2182 {
2183 break; // get out of here!
2184 }
2185 else // !list
2186 {
2187 wxChar ch = ftp->SendCommand(buf);
2188 wxPrintf(wxT("Command %s"), ch ? wxT("succeeded") : wxT("failed"));
2189 if ( ch )
2190 {
2191 wxPrintf(wxT(" (return code %c)"), ch);
2192 }
2193
2194 wxPrintf(wxT(", server reply:\n%s\n\n"), ftp->GetLastResult().c_str());
2195 }
2196 }
2197
2198 wxPuts(wxT("\n"));
2199 }
2200 #endif // TEST_INTERACTIVE
2201 #endif // TEST_FTP
2202
2203 // ----------------------------------------------------------------------------
2204 // stack backtrace
2205 // ----------------------------------------------------------------------------
2206
2207 #ifdef TEST_STACKWALKER
2208
2209 #if wxUSE_STACKWALKER
2210
2211 #include "wx/stackwalk.h"
2212
2213 class StackDump : public wxStackWalker
2214 {
2215 public:
2216 StackDump(const char *argv0)
2217 : wxStackWalker(argv0)
2218 {
2219 }
2220
2221 virtual void Walk(size_t skip = 1, size_t maxdepth = wxSTACKWALKER_MAX_DEPTH)
2222 {
2223 wxPuts(wxT("Stack dump:"));
2224
2225 wxStackWalker::Walk(skip, maxdepth);
2226 }
2227
2228 protected:
2229 virtual void OnStackFrame(const wxStackFrame& frame)
2230 {
2231 printf("[%2d] ", (int) frame.GetLevel());
2232
2233 wxString name = frame.GetName();
2234 if ( !name.empty() )
2235 {
2236 printf("%-20.40s", (const char*)name.mb_str());
2237 }
2238 else
2239 {
2240 printf("0x%08lx", (unsigned long)frame.GetAddress());
2241 }
2242
2243 if ( frame.HasSourceLocation() )
2244 {
2245 printf("\t%s:%d",
2246 (const char*)frame.GetFileName().mb_str(),
2247 (int)frame.GetLine());
2248 }
2249
2250 puts("");
2251
2252 wxString type, val;
2253 for ( size_t n = 0; frame.GetParam(n, &type, &name, &val); n++ )
2254 {
2255 printf("\t%s %s = %s\n", (const char*)type.mb_str(),
2256 (const char*)name.mb_str(),
2257 (const char*)val.mb_str());
2258 }
2259 }
2260 };
2261
2262 static void TestStackWalk(const char *argv0)
2263 {
2264 wxPuts(wxT("*** Testing wxStackWalker ***"));
2265
2266 StackDump dump(argv0);
2267 dump.Walk();
2268
2269 wxPuts("\n");
2270 }
2271
2272 #endif // wxUSE_STACKWALKER
2273
2274 #endif // TEST_STACKWALKER
2275
2276 // ----------------------------------------------------------------------------
2277 // standard paths
2278 // ----------------------------------------------------------------------------
2279
2280 #ifdef TEST_STDPATHS
2281
2282 #include "wx/stdpaths.h"
2283 #include "wx/wxchar.h" // wxPrintf
2284
2285 static void TestStandardPaths()
2286 {
2287 wxPuts(wxT("*** Testing wxStandardPaths ***"));
2288
2289 wxTheApp->SetAppName(wxT("console"));
2290
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
2306 (
2307 wxT("fr"),
2308 wxStandardPaths::ResourceCat_Messages
2309 ).c_str());
2310
2311 wxPuts("\n");
2312 }
2313
2314 #endif // TEST_STDPATHS
2315
2316 // ----------------------------------------------------------------------------
2317 // wxVolume tests
2318 // ----------------------------------------------------------------------------
2319
2320 #if !defined(__WIN32__) || !wxUSE_FSVOLUME
2321 #undef TEST_VOLUME
2322 #endif
2323
2324 #ifdef TEST_VOLUME
2325
2326 #include "wx/volume.h"
2327
2328 static const wxChar *volumeKinds[] =
2329 {
2330 wxT("floppy"),
2331 wxT("hard disk"),
2332 wxT("CD-ROM"),
2333 wxT("DVD-ROM"),
2334 wxT("network volume"),
2335 wxT("other volume"),
2336 };
2337
2338 static void TestFSVolume()
2339 {
2340 wxPuts(wxT("*** Testing wxFSVolume class ***"));
2341
2342 wxArrayString volumes = wxFSVolume::GetVolumes();
2343 size_t count = volumes.GetCount();
2344
2345 if ( !count )
2346 {
2347 wxPuts(wxT("ERROR: no mounted volumes?"));
2348 return;
2349 }
2350
2351 wxPrintf(wxT("%u mounted volumes found:\n"), count);
2352
2353 for ( size_t n = 0; n < count; n++ )
2354 {
2355 wxFSVolume vol(volumes[n]);
2356 if ( !vol.IsOk() )
2357 {
2358 wxPuts(wxT("ERROR: couldn't create volume"));
2359 continue;
2360 }
2361
2362 wxPrintf(wxT("%u: %s (%s), %s, %s, %s\n"),
2363 n + 1,
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")
2369 : wxT("fixed"));
2370 }
2371
2372 wxPuts("\n");
2373 }
2374
2375 #endif // TEST_VOLUME
2376
2377 // ----------------------------------------------------------------------------
2378 // date time
2379 // ----------------------------------------------------------------------------
2380
2381 #ifdef TEST_DATETIME
2382
2383 #include "wx/math.h"
2384 #include "wx/datetime.h"
2385
2386 #if TEST_INTERACTIVE
2387
2388 static void TestDateTimeInteractive()
2389 {
2390 wxPuts(wxT("\n*** interactive wxDateTime tests ***"));
2391
2392 wxChar buf[128];
2393
2394 for ( ;; )
2395 {
2396 wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
2397 if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
2398 break;
2399
2400 // kill the last '\n'
2401 buf[wxStrlen(buf) - 1] = 0;
2402
2403 if ( wxString(buf).CmpNoCase("quit") == 0 )
2404 break;
2405
2406 wxDateTime dt;
2407 const wxChar *p = dt.ParseDate(buf);
2408 if ( !p )
2409 {
2410 wxPrintf(wxT("ERROR: failed to parse the date '%s'.\n"), buf);
2411
2412 continue;
2413 }
2414 else if ( *p )
2415 {
2416 wxPrintf(wxT("WARNING: parsed only first %u characters.\n"), p - buf);
2417 }
2418
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(),
2421 dt.GetDayOfYear(),
2422 dt.GetWeekOfMonth(wxDateTime::Monday_First),
2423 dt.GetWeekOfMonth(wxDateTime::Sunday_First),
2424 dt.GetWeekOfYear(wxDateTime::Monday_First));
2425 }
2426
2427 wxPuts("\n");
2428 }
2429
2430 #endif // TEST_INTERACTIVE
2431 #endif // TEST_DATETIME
2432
2433 // ----------------------------------------------------------------------------
2434 // single instance
2435 // ----------------------------------------------------------------------------
2436
2437 #ifdef TEST_SNGLINST
2438
2439 #include "wx/snglinst.h"
2440
2441 static bool TestSingleIstance()
2442 {
2443 wxPuts(wxT("\n*** Testing wxSingleInstanceChecker ***"));
2444
2445 wxSingleInstanceChecker checker;
2446 if ( checker.Create(wxT(".wxconsole.lock")) )
2447 {
2448 if ( checker.IsAnotherRunning() )
2449 {
2450 wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
2451
2452 return false;
2453 }
2454
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..."));
2458 wxFgetc(stdin);
2459 }
2460 else // failed to create
2461 {
2462 wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
2463 }
2464
2465 wxPuts("\n");
2466
2467 return true;
2468 }
2469 #endif // TEST_SNGLINST
2470
2471
2472 // ----------------------------------------------------------------------------
2473 // entry point
2474 // ----------------------------------------------------------------------------
2475
2476 int main(int argc, char **argv)
2477 {
2478 #if wxUSE_UNICODE
2479 wxChar **wxArgv = new wxChar *[argc + 1];
2480
2481 {
2482 int n;
2483
2484 for (n = 0; n < argc; n++ )
2485 {
2486 wxMB2WXbuf warg = wxConvertMB2WX(argv[n]);
2487 wxArgv[n] = wxStrdup(warg);
2488 }
2489
2490 wxArgv[n] = NULL;
2491 }
2492 #else // !wxUSE_UNICODE
2493 #define wxArgv argv
2494 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
2495
2496 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
2497
2498 wxInitializer initializer;
2499 if ( !initializer )
2500 {
2501 fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
2502
2503 return -1;
2504 }
2505
2506 #ifdef TEST_SNGLINST
2507 if (!TestSingleIstance())
2508 return 1;
2509 #endif // TEST_SNGLINST
2510
2511 #ifdef TEST_DIR
2512 #if TEST_ALL
2513 TestDirExists();
2514 TestDirEnum();
2515 #endif
2516 TestDirTraverse();
2517 #endif // TEST_DIR
2518
2519 #ifdef TEST_DYNLIB
2520 TestDllLoad();
2521 TestDllListLoaded();
2522 #endif // TEST_DYNLIB
2523
2524 #ifdef TEST_ENVIRON
2525 TestEnvironment();
2526 #endif // TEST_ENVIRON
2527
2528 #ifdef TEST_FILECONF
2529 TestFileConfRead();
2530 #endif // TEST_FILECONF
2531
2532 #ifdef TEST_LOCALE
2533 TestDefaultLang();
2534 #endif // TEST_LOCALE
2535
2536 #ifdef TEST_LOG
2537 wxPuts(wxT("*** Testing wxLog ***"));
2538
2539 wxString s;
2540 for ( size_t n = 0; n < 8000; n++ )
2541 {
2542 s << (wxChar)(wxT('A') + (n % 26));
2543 }
2544
2545 wxLogWarning(wxT("The length of the string is %lu"),
2546 (unsigned long)s.length());
2547
2548 wxString msg;
2549 msg.Printf(wxT("A very very long message: '%s', the end!\n"), s.c_str());
2550
2551 // this one shouldn't be truncated
2552 wxPrintf(msg);
2553
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
2556 // by wxLog anyhow)
2557 wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s.c_str());
2558 #endif // TEST_LOG
2559
2560 #ifdef TEST_FILE
2561 TestFileRead();
2562 TestTextFileRead();
2563 TestFileCopy();
2564 TestTempFile();
2565 #endif // TEST_FILE
2566
2567 #ifdef TEST_FILENAME
2568 TestFileNameTemp();
2569 TestFileNameCwd();
2570 TestFileNameDirManip();
2571 TestFileNameComparison();
2572 TestFileNameOperations();
2573 #endif // TEST_FILENAME
2574
2575 #ifdef TEST_FILETIME
2576 TestFileGetTimes();
2577 #if 0
2578 TestFileSetTimes();
2579 #endif
2580 #endif // TEST_FILETIME
2581
2582 #ifdef TEST_FTP
2583 wxLog::AddTraceMask(FTP_TRACE_MASK);
2584
2585 // wxFTP cannot be a static variable as its ctor needs to access
2586 // wxWidgets internals after it has been initialized
2587 ftp = new wxFTP;
2588 ftp->SetLog(new wxProtocolLog(FTP_TRACE_MASK));
2589 if ( TestFtpConnect() )
2590 TestFtpInteractive();
2591 //else: connecting to the FTP server failed
2592
2593 delete ftp;
2594 #endif // TEST_FTP
2595
2596 #ifdef TEST_MIME
2597 //wxLog::AddTraceMask(wxT("mime"));
2598 TestMimeEnum();
2599 #if 0
2600 TestMimeOverride();
2601 TestMimeAssociate();
2602 #endif
2603 TestMimeFilename();
2604 #endif // TEST_MIME
2605
2606 #ifdef TEST_INFO_FUNCTIONS
2607 TestOsInfo();
2608 TestPlatformInfo();
2609 TestUserInfo();
2610
2611 #if TEST_INTERACTIVE
2612 TestDiskInfo();
2613 #endif
2614 #endif // TEST_INFO_FUNCTIONS
2615
2616 #ifdef TEST_PATHLIST
2617 TestPathList();
2618 #endif // TEST_PATHLIST
2619
2620 #ifdef TEST_PRINTF
2621 TestPrintf();
2622 #endif // TEST_PRINTF
2623
2624 #ifdef TEST_REGCONF
2625 #if 0
2626 TestRegConfWrite();
2627 #endif
2628 TestRegConfRead();
2629 #endif // TEST_REGCONF
2630
2631 #if defined TEST_REGEX && TEST_INTERACTIVE
2632 TestRegExInteractive();
2633 #endif // defined TEST_REGEX && TEST_INTERACTIVE
2634
2635 #ifdef TEST_REGISTRY
2636 TestRegistryRead();
2637 TestRegistryAssociation();
2638 #endif // TEST_REGISTRY
2639
2640 #ifdef TEST_DATETIME
2641 #if TEST_INTERACTIVE
2642 TestDateTimeInteractive();
2643 #endif
2644 #endif // TEST_DATETIME
2645
2646 #ifdef TEST_STACKWALKER
2647 #if wxUSE_STACKWALKER
2648 TestStackWalk(argv[0]);
2649 #endif
2650 #endif // TEST_STACKWALKER
2651
2652 #ifdef TEST_STDPATHS
2653 TestStandardPaths();
2654 #endif
2655
2656 #ifdef TEST_USLEEP
2657 wxPuts(wxT("Sleeping for 3 seconds... z-z-z-z-z..."));
2658 wxUsleep(3000);
2659 #endif // TEST_USLEEP
2660
2661 #ifdef TEST_VOLUME
2662 TestFSVolume();
2663 #endif // TEST_VOLUME
2664
2665 #if wxUSE_UNICODE
2666 {
2667 for ( int n = 0; n < argc; n++ )
2668 free(wxArgv[n]);
2669
2670 delete [] wxArgv;
2671 }
2672 #endif // wxUSE_UNICODE
2673
2674 wxUnusedVar(argc);
2675 wxUnusedVar(argv);
2676 return 0;
2677 }