[Libreoffice-commits] core.git: Branch 'aoo/trunk' - comphelper/GoogleTest_comphelper_string.mk comphelper/GoogleTest_comphelper_weakbag.mk comphelper/Module_comphelper.mk comphelper/qa
Damjan Jovanovic
damjan at apache.org
Sun Oct 4 07:09:05 PDT 2015
comphelper/GoogleTest_comphelper_string.mk | 51 +++++++++++++++++++++++++++
comphelper/GoogleTest_comphelper_weakbag.mk | 50 ++++++++++++++++++++++++++
comphelper/Module_comphelper.mk | 7 +++
comphelper/qa/makefile.mk | 52 ----------------------------
comphelper/qa/test_string.cxx | 42 ++++++++++------------
comphelper/qa/test_weakbag.cxx | 50 +++++++++++++-------------
comphelper/qa/version.map | 30 ----------------
7 files changed, 153 insertions(+), 129 deletions(-)
New commits:
commit 9cbc61419ad4ef0883a543a2111dae28e25a5214
Author: Damjan Jovanovic <damjan at apache.org>
Date: Sun Oct 4 13:46:56 2015 +0000
#i125003# migrate main/comphelper from cppunit to Google Test, fix the broken string test,
and run the tests on every build.
diff --git a/comphelper/qa/version.map b/comphelper/GoogleTest_comphelper_string.mk
similarity index 59%
rename from comphelper/qa/version.map
rename to comphelper/GoogleTest_comphelper_string.mk
index f12a8b2..39f170d 100644
--- a/comphelper/qa/version.map
+++ b/comphelper/GoogleTest_comphelper_string.mk
@@ -1,5 +1,5 @@
#**************************************************************
-#
+#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -7,24 +7,45 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#
+#
#**************************************************************
-UDK_3_0_0 {
- global:
- registerAllTestFunction;
+$(eval $(call gb_GoogleTest_GoogleTest,comphelper_string))
- local:
- *;
-};
+$(eval $(call gb_GoogleTest_add_exception_objects,comphelper_string, \
+ comphelper/qa/test_string \
+))
+
+$(eval $(call gb_GoogleTest_add_linked_libs,comphelper_string, \
+ comphelper \
+ cppuhelper \
+ cppu \
+ sal \
+ stl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_GoogleTest_set_include,comphelper_string,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/formula/inc \
+ -I$(SRCDIR)/comphelper/inc/pch \
+ -I$(OUTDIR)/inc/offuh \
+ -I$(OUTDIR)/inc \
+))
+
+$(eval $(call gb_GoogleTest_set_ldflags,comphelper_string,\
+ $$(LDFLAGS) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/comphelper/qa/makefile.mk b/comphelper/GoogleTest_comphelper_weakbag.mk
similarity index 61%
rename from comphelper/qa/makefile.mk
rename to comphelper/GoogleTest_comphelper_weakbag.mk
index ac7ce9d..bb936b6 100644
--- a/comphelper/qa/makefile.mk
+++ b/comphelper/GoogleTest_comphelper_weakbag.mk
@@ -21,32 +21,30 @@
-PRJ := ..
-PRJNAME := comphelper
-TARGET := qa
-
-ENABLE_EXCEPTIONS := TRUE
-
-.INCLUDE: settings.mk
-
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
-DLLPRE = # no leading "lib" on .so files
-
-INCPRE += $(MISC)$/$(TARGET)$/inc
-
-SHL1TARGET = $(TARGET)_weakbag
-SHL1OBJS = $(SLO)$/test_weakbag.obj
-SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB)
-SHL1VERSIONMAP = version.map
-SHL1IMPLIB = i$(SHL1TARGET)
-DEF1NAME = $(SHL1TARGET)
-
-SLOFILES = $(SHL1OBJS)
-
-.INCLUDE: target.mk
-
-ALLTAR: test
-
-test .PHONY: $(SHL1TARGETN)
- $(TESTSHL2) $(SHL1TARGETN)
+$(eval $(call gb_GoogleTest_GoogleTest,comphelper_weakbag))
+
+$(eval $(call gb_GoogleTest_add_exception_objects,comphelper_weakbag, \
+ comphelper/qa/test_weakbag \
+))
+
+$(eval $(call gb_GoogleTest_add_linked_libs,comphelper_weakbag, \
+ cppuhelper \
+ cppu \
+ sal \
+ stl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_GoogleTest_set_include,comphelper_weakbag,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/formula/inc \
+ -I$(SRCDIR)/comphelper/inc/pch \
+ -I$(OUTDIR)/inc/offuh \
+ -I$(OUTDIR)/inc \
+))
+
+$(eval $(call gb_GoogleTest_set_ldflags,comphelper_weakbag,\
+ $$(LDFLAGS) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/comphelper/Module_comphelper.mk b/comphelper/Module_comphelper.mk
index 3e192e53..4bee63b 100644
--- a/comphelper/Module_comphelper.mk
+++ b/comphelper/Module_comphelper.mk
@@ -28,6 +28,13 @@ $(eval $(call gb_Module_add_targets,comphelper,\
Library_comphelp \
))
+ifeq ($(ENABLE_UNIT_TESTS),YES)
+$(eval $(call gb_Module_add_check_targets,comphelper,\
+ GoogleTest_comphelper_string \
+ GoogleTest_comphelper_weakbag \
+))
+endif
+
ifneq ($(OOO_JUNIT_JAR),)
$(eval $(call gb_Module_add_subsequentcheck_targets,comphelper,\
JunitTest_comphelper_complex \
diff --git a/comphelper/qa/test_string.cxx b/comphelper/qa/test_string.cxx
index fa5d57d..43576f3 100644
--- a/comphelper/qa/test_string.cxx
+++ b/comphelper/qa/test_string.cxx
@@ -25,7 +25,7 @@
#include "sal/config.h"
#include "comphelper/string.hxx"
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
#include "rtl/string.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
@@ -33,46 +33,44 @@
namespace {
-class Test: public CppUnit::TestFixture {
+class Test: public ::testing::Test {
public:
- void test();
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test);
- CPPUNIT_TEST_SUITE_END();
};
-void Test::test() {
+TEST_F(Test, test) {
rtl::OUString s1(RTL_CONSTASCII_USTRINGPARAM("foobarbar"));
sal_Int32 n1;
rtl::OUString s2(
- comphelper::string::searchAndReplace(
- s1, RTL_CONSTASCII_STRINGPARAM("bar"),
+ comphelper::string::searchAndReplaceAsciiI(
+ s1, rtl::OString(RTL_CONSTASCII_STRINGPARAM("bar")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baaz")), 0, &n1));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
s2 == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foobaazbar")));
- CPPUNIT_ASSERT(n1 == 3);
+ ASSERT_TRUE(n1 == 3);
sal_Int32 n2;
rtl::OUString s3(
- comphelper::string::searchAndReplace(
- s2, RTL_CONSTASCII_STRINGPARAM("bar"),
+ comphelper::string::searchAndReplaceAsciiI(
+ s2, rtl::OString(RTL_CONSTASCII_STRINGPARAM("bar")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bz")),
n1 + RTL_CONSTASCII_LENGTH("baaz"), &n2));
- CPPUNIT_ASSERT(
+ ASSERT_TRUE(
s3 == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foobaazbz")));
- CPPUNIT_ASSERT(n2 == 7);
+ ASSERT_TRUE(n2 == 7);
sal_Int32 n3;
rtl::OUString s4(
- comphelper::string::searchAndReplace(
- s3, RTL_CONSTASCII_STRINGPARAM("bar"),
+ comphelper::string::searchAndReplaceAsciiI(
+ s3, rtl::OString(RTL_CONSTASCII_STRINGPARAM("bar")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baz")),
n2 + RTL_CONSTASCII_LENGTH("bz"), &n3));
- CPPUNIT_ASSERT(s4 == s3);
- CPPUNIT_ASSERT(n3 == -1);
+ ASSERT_TRUE(s4 == s3);
+ ASSERT_TRUE(n3 == -1);
}
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
}
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/comphelper/qa/test_weakbag.cxx b/comphelper/qa/test_weakbag.cxx
index 06c4354..ef4a499 100644
--- a/comphelper/qa/test_weakbag.cxx
+++ b/comphelper/qa/test_weakbag.cxx
@@ -28,39 +28,39 @@
#include "com/sun/star/uno/XInterface.hpp"
#include "comphelper/weakbag.hxx"
#include "cppuhelper/weak.hxx"
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
namespace {
namespace css = com::sun::star;
-class Test: public CppUnit::TestFixture {
+class Test: public ::testing::Test {
public:
- void test() {
- css::uno::Reference< css::uno::XInterface > ref1(new cppu::OWeakObject);
- css::uno::Reference< css::uno::XInterface > ref2(new cppu::OWeakObject);
- css::uno::Reference< css::uno::XInterface > ref3(new cppu::OWeakObject);
- comphelper::WeakBag< css::uno::XInterface > bag;
- bag.add(ref1);
- bag.add(ref1);
- bag.add(ref2);
- bag.add(ref2);
- ref1.clear();
- bag.add(ref3);
- ref3.clear();
- CPPUNIT_ASSERT_MESSAGE("remove first ref2", bag.remove() == ref2);
- CPPUNIT_ASSERT_MESSAGE("remove second ref2", bag.remove() == ref2);
- CPPUNIT_ASSERT_MESSAGE("remove first null", !bag.remove().is());
- CPPUNIT_ASSERT_MESSAGE("remove second null", !bag.remove().is());
- }
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test);
- CPPUNIT_TEST_SUITE_END();
};
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
+TEST_F(Test, test) {
+ css::uno::Reference< css::uno::XInterface > ref1(new cppu::OWeakObject);
+ css::uno::Reference< css::uno::XInterface > ref2(new cppu::OWeakObject);
+ css::uno::Reference< css::uno::XInterface > ref3(new cppu::OWeakObject);
+ comphelper::WeakBag< css::uno::XInterface > bag;
+ bag.add(ref1);
+ bag.add(ref1);
+ bag.add(ref2);
+ bag.add(ref2);
+ ref1.clear();
+ bag.add(ref3);
+ ref3.clear();
+ ASSERT_TRUE(bag.remove() == ref2) << "remove first ref2";
+ ASSERT_TRUE(bag.remove() == ref2) << "remove second ref2";
+ ASSERT_TRUE(!bag.remove().is()) << "remove first null";
+ ASSERT_TRUE(!bag.remove().is()) << "remove second null";
+}
+
}
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
More information about the Libreoffice-commits
mailing list