[Libreoffice-commits] core.git: sal/cppunittester

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Jan 26 06:57:44 PST 2016


 sal/cppunittester/cppunittester.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 2a3a9dec50068321125e4a76de7042bf2d741bc7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jan 26 10:30:47 2016 +0100

    support unnamed namespaces with CPPUNIT_TEST_NAME
    
    Change-Id: I1ce50ce0ce8a4a461d1b2a34de132cbf57dd7d25
    Reviewed-on: https://gerrit.libreoffice.org/21802
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at 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);
     }
 }


More information about the Libreoffice-commits mailing list