private:
void List(Test *test, const string& parent = "") const;
+ // call List() if m_list or runner.addTest() otherwise
+ void AddTest(CppUnit::TestRunner& runner, Test *test)
+ {
+ if (m_list)
+ List(test);
+ else
+ runner.addTest(test);
+ }
+
// command lines options/parameters
bool m_list;
bool m_longlist;
bool m_detail;
bool m_timing;
wxArrayString m_registries;
+ wxLocale *m_locale;
// event handling hooks
FilterEventFunc m_filterEventFunc;
{
m_filterEventFunc = NULL;
m_processEventFunc = NULL;
+
+ m_locale = NULL;
}
// Init
{ wxCMD_LINE_SWITCH, "t", "timing",
"print names and mesure running time of individual test, run them",
wxCMD_LINE_VAL_NONE, 0 },
+ { wxCMD_LINE_OPTION, "", "locale",
+ "locale to use when running the program",
+ wxCMD_LINE_VAL_STRING, 0 },
{ wxCMD_LINE_PARAM, NULL, NULL, "REGISTRY", wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
wxCMD_LINE_DESC_END
bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
if (parser.GetParamCount())
+ {
for (size_t i = 0; i < parser.GetParamCount(); i++)
m_registries.push_back(parser.GetParam(i));
- else
- m_registries.push_back("");
+ }
+
+ m_longlist = parser.Found("longlist");
+ m_list = m_longlist || parser.Found("list");
+ m_timing = parser.Found("timing");
+ m_detail = !m_timing && parser.Found("detail");
+
+ wxString loc;
+ if ( parser.Found("locale", &loc) )
+ {
+ const wxLanguageInfo * const info = wxLocale::FindLanguageInfo(loc);
+ if ( !info )
+ {
+ cerr << "Locale \"" << string(loc.mb_str()) << "\" is unknown.\n";
+ return false;
+ }
- m_longlist = parser.Found(_T("longlist"));
- m_list = m_longlist || parser.Found(_T("list"));
- m_timing = parser.Found(_T("timing"));
- m_detail = !m_timing && parser.Found(_T("detail"));
+ m_locale = new wxLocale(info->Language);
+ if ( !m_locale->IsOk() )
+ {
+ cerr << "Using locale \"" << string(loc.mb_str()) << "\" failed.\n";
+ return false;
+ }
+ }
return TestAppBase::OnCmdLineParsed(parser);
}
CppUnit::TextTestRunner runner;
- for (size_t i = 0; i < m_registries.size(); i++)
+ if ( m_registries.empty() )
{
- Test *test;
-
- wxString reg = m_registries[i];
- if ( reg.empty() )
- {
- // no test name, run all the tests
- test = TestFactoryRegistry::getRegistry().makeTest();
- }
- else // test name specified, run just this test
+ // run or list all tests
+ AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());
+ }
+ else // run only the selected tests
+ {
+ for (size_t i = 0; i < m_registries.size(); i++)
{
- test = GetTestByName(reg);
+ const wxString reg = m_registries[i];
+ Test *test = GetTestByName(reg);
if ( !test && !reg.EndsWith("TestCase") )
{
cerr << "No such test suite: " << string(reg.mb_str()) << endl;
return 2;
}
- }
- if (m_list)
- List(test);
- else
- runner.addTest(test);
+ AddTest(runner, test);
+ }
}
if ( m_list )
int TestApp::OnExit()
{
+ delete m_locale;
+
#if wxUSE_GUI
delete GetTopWindow();
#endif // wxUSE_GUI