24 typedef std::pair<std::string, std::string>
TestName;
32 const std::string& test
35 const size_t separatorAt = test.find(
":");
36 if(std::string::npos == separatorAt)
38 return std::make_pair(test, std::string());
40 else if((0 == separatorAt) || (test.length() -1 == separatorAt))
42 return std::make_pair(std::string(), std::string());
46 return std::make_pair(test.substr(0, separatorAt), test.substr(separatorAt + 1));
61 const char*
const name,
70 const std::string&
test
99 std::vector<std::string>
names;
106 out <<
"Available Test Suites:\n";
107 for(
const auto& name :
names)
109 out <<
"\t" << name <<
"\n";
111 out <<
suites.size() <<
" Test Suites\n";
118 std::vector<std::string>
names;
125 out <<
"Available Test Cases:\n";
127 for(
const auto& name :
names)
132 out <<
"INTERNAL ERROR: Failed to find Test Suite " << name <<
"\n";
136 count +=
suite->second->listTestCases(out);
139 out << count <<
" Test Cases\n";
Count of tests run, and fails.
Interface for logging events while running tests.
Defines and runs a single Test Case within a Test Suite.
bool run(TestSuite &suite, Logger &logger) const
Run this Test Case as part of suite, logging events to logger.
Singleton that collects all TEST_SUITE()s, to run on demand.
bool isValid(const std::string &test) const
Determine if test can be run as one of: a valid Test Suite, or Test Suite:Test Case.
std::vector< std::string > TestNames
List of Test Names as: "<suite>" or "<suite>:<case>".
Count run(Logger &logger) const
Run all tests that have been add()ed.
void listTestSuites(std::ostream &out) const
List available Test Suites to out.
void add(const char *const name, TestSuiteInterface *const suite)
Add the suite by name.
static TestRunner & get()
Get the singleton.
void listTestCases(std::ostream &out) const
List available Test Cases to out.
std::map< std::string, TestSuiteInterface * > suites
Mapping of test suite name to test suite.
Interface for Test Suites.
std::pair< std::string, std::string > TestName
A parsed Test name as a Test Suite name (.first), and a Test Case name (.second).
TestName parseTestName(const std::string &test)
Parse test into a Test Suite Name and a Test Case name, which would be separated by a ":".