X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a81f30662b64fd900dacda249d3304c45eb32a53..85ac8ca017a0409e9762ed305ccc1d32a7c28fa7:/tests/test.cpp diff --git a/tests/test.cpp b/tests/test.cpp index 4a3618deff..040ed7eeda 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -45,7 +45,7 @@ public: int OnRun(); private: - void List(Test *test, int depth = 0) const; + void List(Test *test, const string& parent = "") const; // command lines options/parameters bool m_list; @@ -56,7 +56,8 @@ private: IMPLEMENT_APP_CONSOLE(TestApp) TestApp::TestApp() - : m_list(false) + : m_list(false), + m_longlist(false) { } @@ -137,20 +138,37 @@ int TestApp::OnRun() // List the tests // -void TestApp::List(Test *test, int depth /*=0*/) const +void TestApp::List(Test *test, const string& parent /*=""*/) const { TestSuite *suite = dynamic_cast(test); - - if (suite || m_longlist) - cout << string(depth * 2, ' ') << test->getName() << "\n"; + string name; if (suite) { - typedef const vector Tests; + // take the last component of the name and append to the parent + name = test->getName(); + string::size_type i = name.find_last_of(".:"); + name = parent + "." + (i != string::npos ? name.substr(i + 1) : name); + + // drop the 1st component from the display and indent + if (parent != "") { + string::size_type j = i = name.find('.', 1); + while ((j = name.find('.', j + 1)) != string::npos) + cout << " "; + cout << " " << name.substr(i + 1) << "\n"; + } + + typedef vector Tests; typedef Tests::const_iterator Iter; - Tests& tests = suite->getTests(); + const Tests& tests = suite->getTests(); for (Iter it = tests.begin(); it != tests.end(); ++it) - List(*it, depth + 1); + List(*it, name); + } + else if (m_longlist) { + string::size_type i = 0; + while ((i = parent.find('.', i + 1)) != string::npos) + cout << " "; + cout << " " << test->getName() << "\n"; } }