]>
Commit | Line | Data |
---|---|---|
cfee166d JS |
1 | /* |
2 | * Tester for wxFormatConverter, by M. J. Wetherell | |
3 | * | |
4 | * Reads stdin, expects two column input (as produced by formats.pl or | |
5 | * formats2.pl), the first column contains the test pattern, the second | |
6 | * the expected result. | |
7 | * | |
8 | * The output is any patterns that wxFormatConveter doesn't transform to the | |
9 | * expected value, in three columns: input, expected, output. | |
10 | * | |
11 | * ./formats.pl | ./formattest | |
12 | * ./formats2.pl | ./formattest | |
13 | */ | |
14 | ||
15 | #include <wx/wx.h> | |
16 | #include <wx/wfstream.h> | |
17 | #include <wx/txtstrm.h> | |
18 | #include <iostream> | |
19 | ||
20 | /* This function is in wxchar.cpp to give access to wxFormatConverter, | |
21 | * but only in debug mode. | |
22 | */ | |
23 | ||
24 | #ifdef __WXDEBUG__ | |
25 | extern wxString wxConvertFormat(const wxChar *format); | |
26 | #endif | |
27 | ||
28 | class TestApp : public wxAppConsole | |
29 | { | |
30 | public: | |
31 | int OnRun(); | |
32 | }; | |
33 | ||
34 | IMPLEMENT_APP_CONSOLE(TestApp) | |
35 | ||
36 | int TestApp::OnRun() | |
37 | { | |
38 | #ifdef __WXDEBUG__ | |
39 | wxFFileInputStream in(stdin); | |
40 | wxTextInputStream txt(in, _T("\t")); | |
41 | ||
42 | for (;;) { | |
43 | wxString format = txt.ReadWord(); | |
44 | wxString expected = txt.ReadWord(); | |
45 | if (!in) break; | |
46 | wxString converted = wxConvertFormat(format); | |
47 | ||
48 | if (converted != expected) | |
49 | std::cout << "'" << format.mb_str() << "'\t" | |
50 | << "'" << expected.mb_str() << "'\t" | |
51 | << "'" << converted.mb_str() << "'\n"; | |
52 | } | |
53 | #else | |
54 | std::cout << "Please compile this test program in debug mode.\n"; | |
55 | #endif | |
56 | return 0; | |
57 | } | |
58 |