Author: damjan Date: Sun Oct 4 13:46:56 2015 New Revision: 1706678 URL: http://svn.apache.org/viewvc?rev=1706678&view=rev Log: #i125003# migrate main/comphelper from cppunit to Google Test, fix the broken string test, and run the tests on every build.
Added: openoffice/trunk/main/comphelper/GoogleTest_comphelper_string.mk openoffice/trunk/main/comphelper/GoogleTest_comphelper_weakbag.mk Removed: openoffice/trunk/main/comphelper/qa/makefile.mk openoffice/trunk/main/comphelper/qa/version.map Modified: openoffice/trunk/main/comphelper/Module_comphelper.mk openoffice/trunk/main/comphelper/qa/test_string.cxx openoffice/trunk/main/comphelper/qa/test_weakbag.cxx Added: openoffice/trunk/main/comphelper/GoogleTest_comphelper_string.mk URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/GoogleTest_comphelper_string.mk?rev=1706678&view=auto ============================================================================== --- openoffice/trunk/main/comphelper/GoogleTest_comphelper_string.mk (added) +++ openoffice/trunk/main/comphelper/GoogleTest_comphelper_string.mk Sun Oct 4 13:46:56 2015 @@ -0,0 +1,51 @@ +#************************************************************** +# +# 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 +# regarding copyright ownership. The ASF licenses this file +# 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. +# +#************************************************************** + + + +$(eval $(call gb_GoogleTest_GoogleTest,comphelper_string)) + +$(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: Added: openoffice/trunk/main/comphelper/GoogleTest_comphelper_weakbag.mk URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/GoogleTest_comphelper_weakbag.mk?rev=1706678&view=auto ============================================================================== --- openoffice/trunk/main/comphelper/GoogleTest_comphelper_weakbag.mk (added) +++ openoffice/trunk/main/comphelper/GoogleTest_comphelper_weakbag.mk Sun Oct 4 13:46:56 2015 @@ -0,0 +1,50 @@ +#************************************************************** +# +# 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 +# regarding copyright ownership. The ASF licenses this file +# 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. +# +#************************************************************** + + + +$(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: Modified: openoffice/trunk/main/comphelper/Module_comphelper.mk URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/Module_comphelper.mk?rev=1706678&r1=1706677&r2=1706678&view=diff ============================================================================== --- openoffice/trunk/main/comphelper/Module_comphelper.mk (original) +++ openoffice/trunk/main/comphelper/Module_comphelper.mk Sun Oct 4 13:46:56 2015 @@ -28,6 +28,13 @@ $(eval $(call gb_Module_add_targets,comp 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 \ Modified: openoffice/trunk/main/comphelper/qa/test_string.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/qa/test_string.cxx?rev=1706678&r1=1706677&r2=1706678&view=diff ============================================================================== --- openoffice/trunk/main/comphelper/qa/test_string.cxx (original) +++ openoffice/trunk/main/comphelper/qa/test_string.cxx Sun Oct 4 13:46:56 2015 @@ -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(); +} Modified: openoffice/trunk/main/comphelper/qa/test_weakbag.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/qa/test_weakbag.cxx?rev=1706678&r1=1706677&r2=1706678&view=diff ============================================================================== --- openoffice/trunk/main/comphelper/qa/test_weakbag.cxx (original) +++ openoffice/trunk/main/comphelper/qa/test_weakbag.cxx Sun Oct 4 13:46:56 2015 @@ -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(); +}