diff --git a/alib2algo/test-src/main.cpp b/alib2algo/test-src/main.cpp index 6adad0f4511ce86a7dd9a16dce44c919b47637f3..f2bf8db94da8d4ee7095ac748957aec1fe8c81c2 100644 --- a/alib2algo/test-src/main.cpp +++ b/alib2algo/test-src/main.cpp @@ -21,30 +21,30 @@ CPPUNIT_NS_BEGIN class CPPUNIT_API TestProgressListener : public TestListener { public: - TestProgressListener(); + TestProgressListener(); - virtual ~TestProgressListener(); + virtual ~TestProgressListener(); - void startTest( Test *test ); + void startTest( Test *test ); - void addFailure( const TestFailure &failure ); + void addFailure( const TestFailure &failure ); - void endTest( Test *test ); + void endTest( Test *test ); - int getResult() const; + int getResult() const; - void printResults() const; + void printResults() const; private: - TestProgressListener( const TestProgressListener © ); + TestProgressListener( const TestProgressListener © ); - void operator =( const TestProgressListener © ); + void operator =( const TestProgressListener © ); private: - int m_Failures; - int m_Tests; - int m_Assertions; - bool m_lastTestFailed; + int m_Failures; + int m_Tests; + int m_Assertions; + bool m_lastTestFailed; }; TestProgressListener::TestProgressListener() : m_Failures( 0 ), m_Tests(0), m_Assertions(0), m_lastTestFailed( false ) @@ -79,7 +79,7 @@ void TestProgressListener::endTest( Test * test) stdCOut().flush(); if ( !m_lastTestFailed ) - stdCOut() << " : OK"; + stdCOut() << " : OK"; else stdCOut() << " : Fail"; stdCOut() << "\n\n"; @@ -99,8 +99,8 @@ int main(int argc, char* argv[]) { try { TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01"); - TCLAP::MultiArg<std::string> testPath("p", "path", "test path", false, "string" ); - cmd.add( testPath ); + TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" ); + cmd.add( testPathSegments ); cmd.parse(argc, argv); @@ -113,13 +113,23 @@ int main(int argc, char* argv[]) { controller.addListener( &progressListener ); CppUnit::Test *suite = NULL; - if(testPath.getValue().size() == 0) { + std::string testPath = ""; + if(testPathSegments.getValue().size() == 0) { // Get the top level suite from the registry suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - } else if(testPath.getValue().size() == 1) { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPath.getValue()[0]).makeTest(); + } else if(testPathSegments.getValue().size() == 1) { + suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); } else { - throw TCLAP::ArgException("too many arguments in path switch"); + suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); + bool first = true; + for(const std::string& path : testPathSegments.getValue()) { + if(first) { + first = false; + continue; + } + testPath += path + "/"; + } + testPath.pop_back(); } // Adds the test to the list of test to run @@ -129,7 +139,7 @@ int main(int argc, char* argv[]) { // Change the default outputter to a compiler error format outputter runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. - runner.run( controller ); + runner.run( controller, testPath ); progressListener.printResults(); diff --git a/alib2data/test-src/main.cpp b/alib2data/test-src/main.cpp index 3114b5c8f21a102603ba529cf4c1f6f8a2c684ec..f2bf8db94da8d4ee7095ac748957aec1fe8c81c2 100644 --- a/alib2data/test-src/main.cpp +++ b/alib2data/test-src/main.cpp @@ -99,8 +99,8 @@ int main(int argc, char* argv[]) { try { TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01"); - TCLAP::MultiArg<std::string> testPath("p", "path", "test path", false, "string" ); - cmd.add( testPath ); + TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" ); + cmd.add( testPathSegments ); cmd.parse(argc, argv); @@ -113,13 +113,23 @@ int main(int argc, char* argv[]) { controller.addListener( &progressListener ); CppUnit::Test *suite = NULL; - if(testPath.getValue().size() == 0) { + std::string testPath = ""; + if(testPathSegments.getValue().size() == 0) { // Get the top level suite from the registry suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - } else if(testPath.getValue().size() == 1) { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPath.getValue()[0]).makeTest(); + } else if(testPathSegments.getValue().size() == 1) { + suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); } else { - throw TCLAP::ArgException("too many arguments in path switch"); + suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); + bool first = true; + for(const std::string& path : testPathSegments.getValue()) { + if(first) { + first = false; + continue; + } + testPath += path + "/"; + } + testPath.pop_back(); } // Adds the test to the list of test to run @@ -129,7 +139,7 @@ int main(int argc, char* argv[]) { // Change the default outputter to a compiler error format outputter runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. - runner.run( controller ); + runner.run( controller, testPath ); progressListener.printResults();