void TestRunner::print(const std::string& name, Test* pTest, int indent) { for (int i = 0; i < indent; ++i) _ostr << " "; _ostr << name << std::endl; TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest); if (pSuite) { const std::vector<Test*>& tests = pSuite->tests(); for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it) { print((*it)->toString(), *it, indent + 1); } } }
void TestRunnerDlg::addTest(Test* pTest, int level) { TestInfo ti; ti.pTest = pTest; ti.level = level; _tests.push_back(ti); TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest); if (pSuite) { const std::vector<Test*>& tests = pSuite->tests(); for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it) { addTest(*it, level + 1); } } }
Test* TestRunner::find(const std::string& name, Test* pTest, const std::string& testName) { if (testName.find(name) != std::string::npos) { return pTest; } else { TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest); if (pSuite) { const std::vector<Test*>& tests = pSuite->tests(); for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it) { Test* result = find(name, *it, (*it)->toString()); if (result) return result; } } return 0; } }