cfee166d4e
(M.J.Wetherell) Added wxConvertFormat function in debug mode to allow for unit testing Added tests/formatconverter git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
/*
|
|
* Tester for wxFormatConverter, by M. J. Wetherell
|
|
*
|
|
* Reads stdin, expects two column input (as produced by formats.pl or
|
|
* formats2.pl), the first column contains the test pattern, the second
|
|
* the expected result.
|
|
*
|
|
* The output is any patterns that wxFormatConveter doesn't transform to the
|
|
* expected value, in three columns: input, expected, output.
|
|
*
|
|
* ./formats.pl | ./formattest
|
|
* ./formats2.pl | ./formattest
|
|
*/
|
|
|
|
#include <wx/wx.h>
|
|
#include <wx/wfstream.h>
|
|
#include <wx/txtstrm.h>
|
|
#include <iostream>
|
|
|
|
/* This function is in wxchar.cpp to give access to wxFormatConverter,
|
|
* but only in debug mode.
|
|
*/
|
|
|
|
#ifdef __WXDEBUG__
|
|
extern wxString wxConvertFormat(const wxChar *format);
|
|
#endif
|
|
|
|
class TestApp : public wxAppConsole
|
|
{
|
|
public:
|
|
int OnRun();
|
|
};
|
|
|
|
IMPLEMENT_APP_CONSOLE(TestApp)
|
|
|
|
int TestApp::OnRun()
|
|
{
|
|
#ifdef __WXDEBUG__
|
|
wxFFileInputStream in(stdin);
|
|
wxTextInputStream txt(in, _T("\t"));
|
|
|
|
for (;;) {
|
|
wxString format = txt.ReadWord();
|
|
wxString expected = txt.ReadWord();
|
|
if (!in) break;
|
|
wxString converted = wxConvertFormat(format);
|
|
|
|
if (converted != expected)
|
|
std::cout << "'" << format.mb_str() << "'\t"
|
|
<< "'" << expected.mb_str() << "'\t"
|
|
<< "'" << converted.mb_str() << "'\n";
|
|
}
|
|
#else
|
|
std::cout << "Please compile this test program in debug mode.\n";
|
|
#endif
|
|
return 0;
|
|
}
|
|
|