From 2a3a9dec50068321125e4a76de7042bf2d741bc7 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 26 Jan 2016 10:30:47 +0100 Subject: support unnamed namespaces with CPPUNIT_TEST_NAME Change-Id: I1ce50ce0ce8a4a461d1b2a34de132cbf57dd7d25 Reviewed-on: https://gerrit.libreoffice.org/21802 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard --- sal/cppunittester/cppunittester.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sal') diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index 34911e27e62c..fb9f85f06e00 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -171,13 +171,29 @@ private: namespace { +struct test_name_compare +{ + test_name_compare(const std::string& rName): + maName(rName) + { + } + + bool operator()(const std::string& rCmp) + { + size_t nEndPos = maName.find(rCmp) + rCmp.size(); + return nEndPos == maName.size(); + } + + std::string maName; +}; + void addRecursiveTests(const std::vector& test_names, CppUnit::Test* pTest, CppUnit::TestRunner& rRunner) { for (int i = 0; i < pTest->getChildTestCount(); ++i) { CppUnit::Test* pNewTest = pTest->getChildTestAt(i); addRecursiveTests(test_names, pNewTest, rRunner); - if (std::find(test_names.begin(), test_names.end(), pNewTest->getName()) != test_names.end()) + if (std::find_if(test_names.begin(), test_names.end(), test_name_compare(pNewTest->getName())) != test_names.end()) rRunner.addTest(pNewTest); } } -- cgit