diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 867985852..88034fa11 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -23,7 +23,6 @@ #include #include -#include #include std::ostringstream errout; @@ -33,21 +32,27 @@ std::ostringstream output; * TestRegistry **/ -class TestRegistry { -private: - std::list _tests; +struct CompareFixtures { + bool operator()(const TestFixture* lhs, const TestFixture* rhs) { + return lhs->classname < rhs->classname; + } +}; +typedef std::set TestSet; +class TestRegistry { + TestSet _tests; public: + static TestRegistry &theInstance() { static TestRegistry testreg; return testreg; } void addTest(TestFixture *t) { - _tests.push_back(t); + _tests.insert(t); } - const std::list &tests() const { + const TestSet &tests() const { return _tests; } }; @@ -68,8 +73,8 @@ std::size_t TestFixture::succeeded_todos_counter = 0; std::set TestFixture::missingLibs; TestFixture::TestFixture(const char * const _name) - :classname(_name) - ,quiet_tests(false) + :quiet_tests(false), + classname(_name) { TestRegistry::theInstance().addTest(this); } @@ -287,9 +292,9 @@ std::size_t TestFixture::runTests(const options& args) countTests = 0; errmsg.str(""); - const std::list &tests = TestRegistry::theInstance().tests(); + const TestSet &tests = TestRegistry::theInstance().tests(); - for (std::list::const_iterator it = tests.begin(); it != tests.end(); ++it) { + for (TestSet::const_iterator it = tests.begin(); it != tests.end(); ++it) { if (classname.empty() || (*it)->classname == classname) { (*it)->processOptions(args); (*it)->run(testname); diff --git a/test/testsuite.h b/test/testsuite.h index 67c8c7354..056ac8b5e 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -39,7 +39,6 @@ private: static std::set missingLibs; protected: - std::string classname; std::string testToRun; bool quiet_tests; @@ -73,6 +72,7 @@ public: virtual void reportOut(const std::string &outmsg); virtual void reportErr(const ErrorLogger::ErrorMessage &msg); void run(const std::string &str); + const std::string classname; explicit TestFixture(const char * const _name); virtual ~TestFixture() { }