You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2015/09/20 11:07:55 UTC

svn commit: r1704112 - in /openoffice/trunk/main/sal/qa/systools: makefile.mk test_comtools.cxx

Author: damjan
Date: Sun Sep 20 09:07:54 2015
New Revision: 1704112

URL: http://svn.apache.org/viewvc?rev=1704112&view=rev
Log:
#i125003# migrate main/sal/qa/systools from cppunit to Google Test.


Modified:
    openoffice/trunk/main/sal/qa/systools/makefile.mk
    openoffice/trunk/main/sal/qa/systools/test_comtools.cxx

Modified: openoffice/trunk/main/sal/qa/systools/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/systools/makefile.mk?rev=1704112&r1=1704111&r2=1704112&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/systools/makefile.mk (original)
+++ openoffice/trunk/main/sal/qa/systools/makefile.mk Sun Sep 20 09:07:54 2015
@@ -33,6 +33,12 @@ ENABLE_EXCEPTIONS=TRUE
 
 .INCLUDE :  settings.mk
 
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+	@echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
 CFLAGS+= $(LFS_CFLAGS)
 CXXFLAGS+= $(LFS_CFLAGS)
 
@@ -40,27 +46,19 @@ CFLAGS+=/Ob0
 
 # BEGIN ----------------------------------------------------------------
 # auto generated Target:joblist by codegen.pl
-SHL1OBJS=  \
+APP1OBJS=  \
 	$(SLO)$/test_comtools.obj
 
-SHL1TARGET= test_comtools
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) uuid.lib
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF=    $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME    =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+APP1TARGET= test_comtools
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) uuid.lib
+APP1RPATH = NONE
+APP1TEST = enabled
 # auto generated Target:joblist
 # END ------------------------------------------------------------------
 
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
 
 # --- Targets ------------------------------------------------------
 
 .INCLUDE :  target.mk
-.INCLUDE : _cppunit.mk
 
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"

Modified: openoffice/trunk/main/sal/qa/systools/test_comtools.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/systools/test_comtools.cxx?rev=1704112&r1=1704111&r2=1704112&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/systools/test_comtools.cxx (original)
+++ openoffice/trunk/main/sal/qa/systools/test_comtools.cxx Sun Sep 20 09:07:54 2015
@@ -26,7 +26,7 @@
 #include "precompiled_sal.hxx"
 // autogenerated file with codegen.pl
 
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
 #include <systools/win32/comtools.hxx>
 
 class COMObject : public IUnknown
@@ -99,148 +99,124 @@ void comObjectSource2(LPVOID* ppv)
 namespace test_comtools
 {
 
-    class test_COMReference : public CppUnit::TestFixture
+    class test_COMReference : public ::testing::Test
     {
+    };
 
-    public:
-        /// test of COMReference<IUnknown> r;
-        void default_ctor()
-        {
-            sal::systools::COMReference<IUnknown> r;
-            CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL);
-        }
+    /// test of COMReference<IUnknown> r;
+    TEST_F(test_COMReference, default_ctor)
+    {
+        sal::systools::COMReference<IUnknown> r;
+        ASSERT_TRUE(r.get() == NULL) << "COMReference should be empty";
+    }
 
-        void test_ctor_manual_AddRef()
-        {
-            COMObject* p = new COMObject;
-            p->AddRef();
-            sal::systools::COMReference<IUnknown> r(p, false);
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+    TEST_F(test_COMReference, test_ctor_manual_AddRef)
+    {
+        COMObject* p = new COMObject;
+        p->AddRef();
+        sal::systools::COMReference<IUnknown> r(p, false);
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
 
-        void test_copy_ctor()
-        {
-            sal::systools::COMReference<IUnknown> r(comObjectSource());
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+    TEST_F(test_COMReference, test_copy_ctor)
+    {
+        sal::systools::COMReference<IUnknown> r(comObjectSource());
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
 
-        void test_copy_assignment()
-        {
-            sal::systools::COMReference<IUnknown> r;
-            CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL);
+    TEST_F(test_COMReference, test_copy_assignment)
+    {
+        sal::systools::COMReference<IUnknown> r;
+        ASSERT_TRUE(r.get() == NULL) << "COMReference should be empty";
 
-            r = comObjectSource();
-            CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != NULL);
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+        r = comObjectSource();
+        ASSERT_TRUE(r.get() != NULL) << "COMReference should be empty";
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
 
-        void test_ref_to_ref_assignment()
-        {
-            sal::systools::COMReference<IUnknown> r1 = comObjectSource();
-            sal::systools::COMReference<IUnknown> r2 = r1;
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
-        }
+    TEST_F(test_COMReference, test_ref_to_ref_assignment)
+    {
+        sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+        sal::systools::COMReference<IUnknown> r2 = r1;
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count 2 is expected";
+    }
 
-        void test_pointer_to_ref_assignment()
-        {
-            sal::systools::COMReference<IUnknown> r;
-            r = new COMObject;
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+    TEST_F(test_COMReference, test_pointer_to_ref_assignment)
+    {
+        sal::systools::COMReference<IUnknown> r;
+        r = new COMObject;
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
 
-        void test_pointer_to_ref_assignment2()
-        {
-            sal::systools::COMReference<IUnknown> r = comObjectSource();
-            r = new COMObject;
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+    TEST_F(test_COMReference, test_pointer_to_ref_assignment2)
+    {
+        sal::systools::COMReference<IUnknown> r = comObjectSource();
+        r = new COMObject;
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
 
-        void test_source_sink()
-        {
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 0 is expected", comObjectSink(comObjectSource(), 0));
-        }
+    TEST_F(test_COMReference, test_source_sink)
+    {
+        ASSERT_TRUE(comObjectSink(comObjectSource(), 0)) << "Wrong reference count, 0 is expected";
+    }
 
-        void test_address_operator()
-        {
-            sal::systools::COMReference<IUnknown> r;
-            comObjectSource2(reinterpret_cast<LPVOID*>(&r));
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-        }
+    TEST_F(test_COMReference, test_address_operator)
+    {
+        sal::systools::COMReference<IUnknown> r;
+        comObjectSource2(reinterpret_cast<LPVOID*>(&r));
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count, 1 is expected";
+    }
+
+    TEST_F(test_COMReference, test_address_operator2)
+    {
+        sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+        sal::systools::COMReference<IUnknown> r2 = r1;
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count 2 is expected";
+        comObjectSource2(reinterpret_cast<LPVOID*>(&r1));
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r1.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+    }
+
+    TEST_F(test_COMReference, test_clear)
+    {
+        sal::systools::COMReference<IUnknown> r = comObjectSource();
+        ASSERT_TRUE(reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1) << "Wrong reference count 1 is expected";
+        r.clear();
+        ASSERT_TRUE(!r.is()) << "Expect reference to be empty";
+    }
 
-        void test_address_operator2()
+    TEST_F(test_COMReference, test_query_interface)
+    {
+        try
         {
             sal::systools::COMReference<IUnknown> r1 = comObjectSource();
-            sal::systools::COMReference<IUnknown> r2 = r1;
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
-            comObjectSource2(reinterpret_cast<LPVOID*>(&r1));
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r1.get())->GetRefCount() == 1);
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 1);
+            sal::systools::COMReference<IUnknown> r2 = r1.QueryInterface<IUnknown>(IID_IUnknown);
+            ASSERT_TRUE(reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2) << "Wrong reference count, 2 is expected";
         }
-
-        void test_clear()
+        catch(sal::systools::ComError& ex)
         {
-            sal::systools::COMReference<IUnknown> r = comObjectSource();
-            CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1);
-            r.clear();
-            CPPUNIT_ASSERT_MESSAGE("Expect reference to be empty", !r.is());
+            ASSERT_TRUE(false) << "Exception should not have been thrown";
         }
+    }
 
-        void test_query_interface()
+    TEST_F(test_COMReference, test_query_interface_throw)
+    {
+        try
         {
-            try
-            {
-                sal::systools::COMReference<IUnknown> r1 = comObjectSource();
-                sal::systools::COMReference<IUnknown> r2 = r1.QueryInterface<IUnknown>(IID_IUnknown);
-                CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2);
-            }
-            catch(sal::systools::ComError& ex)
-            {
-                CPPUNIT_ASSERT_MESSAGE("Exception should not have been thrown", false);
-            }
+            sal::systools::COMReference<IUnknown> r1 = comObjectSource();
+            sal::systools::COMReference<IPersistFile> r2 = r1.QueryInterface<IPersistFile>(IID_IPersistFile);
         }
-
-        void test_query_interface_throw()
+        catch(sal::systools::ComError& ex)
         {
-            try
-            {
-                sal::systools::COMReference<IUnknown> r1 = comObjectSource();
-                sal::systools::COMReference<IPersistFile> r2 = r1.QueryInterface<IPersistFile>(IID_IPersistFile);
-            }
-            catch(sal::systools::ComError& ex)
-            {
-                return;
-            }
-            CPPUNIT_ASSERT_MESSAGE("Exception should have been thrown", false);
+            return;
         }
-
-        // Change the following lines only, if you add, remove or rename
-        // member functions of the current class,
-        // because these macros are need by auto register mechanism.
-
-        CPPUNIT_TEST_SUITE(test_COMReference);
-        CPPUNIT_TEST(default_ctor);
-        CPPUNIT_TEST(test_ctor_manual_AddRef);
-        CPPUNIT_TEST(test_copy_ctor);
-        CPPUNIT_TEST(test_copy_assignment);
-        CPPUNIT_TEST(test_ref_to_ref_assignment);
-        CPPUNIT_TEST(test_pointer_to_ref_assignment);
-        CPPUNIT_TEST(test_pointer_to_ref_assignment2);
-        CPPUNIT_TEST(test_source_sink);
-        CPPUNIT_TEST(test_address_operator);
-        CPPUNIT_TEST(test_address_operator2);
-        CPPUNIT_TEST(test_clear);
-        CPPUNIT_TEST(test_query_interface);
-        CPPUNIT_TEST(test_query_interface_throw);
-        CPPUNIT_TEST_SUITE_END();
-    };
-
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_comtools::test_COMReference, "test_comtools");
+        ASSERT_TRUE(false) << "Exception should have been thrown";
+    }
 
 } // namespace rtl_OUString
 
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
-
+int main(int argc, char **argv)
+{
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}