support unnamed namespaces with CPPUNIT_TEST_NAME

Change-Id: I1ce50ce0ce8a4a461d1b2a34de132cbf57dd7d25
Reviewed-on: https://gerrit.libreoffice.org/21802
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index 34911e2..fb9f85f 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<std::string>& 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);
    }
}