Author: damjan
Date: Tue Sep  1 16:55:04 2015
New Revision: 1700616

URL: http://svn.apache.org/r1700616
Log:
#i125003# migrate main/sal/qa/rtl/strings from cppunit to Google Test. Some 
tests fail,
but they don't run during the build and there's no way they passed with cppunit 
either.


Modified:
    openoffice/trunk/main/sal/qa/rtl/strings/makefile.mk
    openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_compare.cxx
    openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_convert.cxx
    openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_endswith.cxx
    openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_noadditional.cxx
    openoffice/trunk/main/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx

Modified: openoffice/trunk/main/sal/qa/rtl/strings/makefile.mk
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/makefile.mk?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/makefile.mk (original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/makefile.mk Tue Sep  1 16:55:04 
2015
@@ -30,22 +30,27 @@ 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)
 
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
-SHL1TARGET := $(TARGET)
-SHL1OBJS := \
+APP1TARGET := $(TARGET)
+APP1OBJS := \
     $(SLO)$/test_oustringbuffer_utf32.obj \
     $(SLO)$/test_oustring_compare.obj \
     $(SLO)$/test_oustring_convert.obj \
     $(SLO)$/test_oustring_endswith.obj \
     $(SLO)$/test_oustring_noadditional.obj
-SHL1IMPLIB := i$(SHL1TARGET)
-SHL1STDLIBS := $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-SHL1VERSIONMAP := $(PRJ)$/qa$/export.map
-DEF1NAME := $(SHL1TARGET)
+APP1STDLIBS := $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
 
 .INCLUDE: target.mk
-.INCLUDE : _cppunit.mk
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"

Modified: openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_compare.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_compare.cxx?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_compare.cxx 
(original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_compare.cxx Tue Sep  
1 16:55:04 2015
@@ -24,40 +24,34 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
 
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
 #include "rtl/string.h"
 #include "rtl/ustring.hxx"
 
 namespace test { namespace oustring {
 
-class Compare: public CppUnit::TestFixture
+class Compare: public ::testing::Test
 {
-private:
-    void equalsIgnoreAsciiCaseAscii();
-
-    CPPUNIT_TEST_SUITE(Compare);
-    CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
-    CPPUNIT_TEST_SUITE_END();
 };
 
-} }
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test::oustring::Compare, "alltest");
-
-void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
+TEST_F(Compare, equalsIgnoreAsciiCaseAscii)
 {
-    CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAscii("abc"));
-    CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAsciiL(
+    ASSERT_TRUE(!rtl::OUString().equalsIgnoreAsciiCaseAscii("abc"));
+    ASSERT_TRUE(!rtl::OUString().equalsIgnoreAsciiCaseAsciiL(
                        RTL_CONSTASCII_STRINGPARAM("abc")));
-    CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
+    ASSERT_TRUE(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
                    equalsIgnoreAsciiCaseAscii(""));
-    CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
+    ASSERT_TRUE(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
                    
equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
 
-    CPPUNIT_ASSERT(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
+    ASSERT_TRUE(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
                    equalsIgnoreAsciiCaseAscii("abc"));
-    CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abcd")).
+    ASSERT_TRUE(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abcd")).
                    equalsIgnoreAsciiCaseAscii("abc"));
-    CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
+    ASSERT_TRUE(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
                    equalsIgnoreAsciiCaseAscii("abcd"));
 }
+
+} }
+
+

Modified: openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_convert.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_convert.cxx?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_convert.cxx 
(original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_convert.cxx Tue Sep  
1 16:55:04 2015
@@ -24,26 +24,11 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
 
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
 #include "rtl/strbuf.hxx"
 #include "rtl/string.hxx"
 #include "rtl/ustring.hxx"
 
-namespace test { namespace oustring {
-
-class Convert: public CppUnit::TestFixture
-{
-private:
-    void convertToString();
-
-    CPPUNIT_TEST_SUITE(Convert);
-    CPPUNIT_TEST(convertToString);
-    CPPUNIT_TEST_SUITE_END();
-};
-
-} }
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test::oustring::Convert, "alltest");
 
 namespace {
 
@@ -89,7 +74,7 @@ void testConvertToString(TestConvertToSt
             aMessage.append(RTL_CONSTASCII_STRINGPARAM("strict = \""));
             aMessage.append(aStrict);
             aMessage.append(RTL_CONSTASCII_STRINGPARAM("\""));
-            CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), false);
+            FAIL() << aMessage.getStr();
         }
     }
     else
@@ -98,13 +83,13 @@ void testConvertToString(TestConvertToSt
         {
             rtl::OStringBuffer aMessage(aPrefix);
             aMessage.append(RTL_CONSTASCII_STRINGPARAM("modified output"));
-            CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), false);
+            FAIL() << aMessage.getStr();
         }
         if (rTest.pStrict != 0)
         {
             rtl::OStringBuffer aMessage(aPrefix);
             aMessage.append(RTL_CONSTASCII_STRINGPARAM("failed"));
-            CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), false);
+            FAIL() << aMessage.getStr();
         }
     }
     if (!aRelaxed.equals(rTest.pRelaxed))
@@ -113,13 +98,20 @@ void testConvertToString(TestConvertToSt
         aMessage.append(RTL_CONSTASCII_STRINGPARAM("relaxed = \""));
         aMessage.append(aRelaxed);
         aMessage.append(RTL_CONSTASCII_STRINGPARAM("\""));
-        CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), false);
+        FAIL() << aMessage.getStr();
     }
 }
 
 }
 
-void test::oustring::Convert::convertToString()
+
+namespace test { namespace oustring {
+
+class Convert: public ::testing::Test
+{
+};
+
+TEST_F(Convert, convertToString)
 {
     TestConvertToString const aTests[]
         = { { { 0 },
@@ -178,3 +170,6 @@ void test::oustring::Convert::convertToS
     for (unsigned int i = 0; i < sizeof aTests / sizeof aTests[0]; ++i)
         testConvertToString(aTests[i]);
 }
+
+} }
+

Modified: openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_endswith.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_endswith.cxx?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_endswith.cxx 
(original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_endswith.cxx Tue Sep 
 1 16:55:04 2015
@@ -24,7 +24,7 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
 
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
 #include "rtl/strbuf.hxx"
 #include "rtl/string.h"
 #include "rtl/string.hxx"
@@ -32,21 +32,7 @@
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
 
-namespace test { namespace oustring {
-
-class EndsWith: public CppUnit::TestFixture
-{
-private:
-    void endsWith();
-
-    CPPUNIT_TEST_SUITE(EndsWith);
-    CPPUNIT_TEST(endsWith);
-    CPPUNIT_TEST_SUITE_END();
-};
-
-} }
 
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test::oustring::EndsWith, "alltest");
 
 namespace {
 
@@ -72,7 +58,15 @@ void appendString(rtl::OStringBuffer & b
 
 }
 
-void test::oustring::EndsWith::endsWith()
+
+
+namespace test { namespace oustring {
+
+class EndsWith: public ::testing::Test
+{
+};
+
+TEST_F(EndsWith, endsWith)
 {
     struct Data {
         char const * str1;
@@ -106,12 +100,13 @@ void test::oustring::EndsWith::endsWith(
         appendString(msg, rtl::OString(data[i].str2, data[i].str2Len));
         msg.append(RTL_CONSTASCII_STRINGPARAM(") == "));
         msg.append(static_cast< sal_Bool >(data[i].endsWith));
-        CPPUNIT_ASSERT_MESSAGE(
-            msg.getStr(),
+        ASSERT_TRUE(
             rtl::OUString(
                 data[i].str1, data[i].str1Len,
                 RTL_TEXTENCODING_ASCII_US).endsWithIgnoreAsciiCaseAsciiL(
                     data[i].str2, data[i].str2Len)
-            == data[i].endsWith);
+            == data[i].endsWith) << msg.getStr();
     }
 }
+
+} }

Modified: 
openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_noadditional.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_noadditional.cxx?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_noadditional.cxx 
(original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/test_oustring_noadditional.cxx Tue 
Sep  1 16:55:04 2015
@@ -24,6 +24,10 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
 
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
 
-NOADDITIONAL;
+int main(int argc, char **argv)
+{
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}

Modified: openoffice/trunk/main/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx?rev=1700616&r1=1700615&r2=1700616&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx 
(original)
+++ openoffice/trunk/main/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx Tue 
Sep  1 16:55:04 2015
@@ -24,29 +24,11 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
 
-#include "testshl/simpleheader.hxx"
+#include "gtest/gtest.h"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 
-namespace test { namespace oustringbuffer {
-
-class Utf32: public CppUnit::TestFixture {
-private:
-    void appendUtf32();
-
-    void insertUtf32();
-
-    CPPUNIT_TEST_SUITE(Utf32);
-    CPPUNIT_TEST(appendUtf32);
-    CPPUNIT_TEST(insertUtf32);
-    CPPUNIT_TEST_SUITE_END();
-};
-
-} }
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test::oustringbuffer::Utf32, "alltest");
-
 namespace {
 
 void appendString(rtl::OUStringBuffer & buffer, rtl::OUString const & string) {
@@ -81,7 +63,13 @@ void createMessage(
 
 }
 
-void test::oustringbuffer::Utf32::appendUtf32() {
+
+namespace test { namespace oustringbuffer {
+
+class Utf32: public ::testing::Test {
+};
+
+TEST_F(Utf32, appendUtf32) {
     int const str1Len = 3;
     sal_Unicode const str1[str1Len] = { 'a', 'b', 'c' };
     int const str2Len = 4;
@@ -93,17 +81,17 @@ void test::oustringbuffer::Utf32::append
     buf1.appendUtf32('d');
     rtl::OUString res1(buf1.makeStringAndClear());
     createMessage(message, res1, rtl::OUString(str2, str2Len));
-    CPPUNIT_ASSERT_MESSAGE(
-        message.getStr(), res1 == rtl::OUString(str2, str2Len));
+    ASSERT_TRUE(
+        res1 == rtl::OUString(str2, str2Len)) << message.getStr();
     rtl::OUStringBuffer buf2(rtl::OUString(str2, str2Len));
     buf2.appendUtf32(0x10000);
     rtl::OUString res2(buf2.makeStringAndClear());
     createMessage(message, res2, rtl::OUString(str3, str3Len));
-    CPPUNIT_ASSERT_MESSAGE(
-        message.getStr(), res2 == rtl::OUString(str3, str3Len));
+    ASSERT_TRUE(
+        res2 == rtl::OUString(str3, str3Len)) << message.getStr();
 }
 
-void test::oustringbuffer::Utf32::insertUtf32() {
+TEST_F(Utf32, insertUtf32) {
     int const str1Len = 3;
     sal_Unicode const str1[str1Len] = { 'a', 'b', 'c' };
     int const str2Len = 4;
@@ -115,12 +103,17 @@ void test::oustringbuffer::Utf32::insert
     buf1.insertUtf32(2, 'd');
     rtl::OUString res1(buf1.makeStringAndClear());
     createMessage(message, res1, rtl::OUString(str2, str2Len));
-    CPPUNIT_ASSERT_MESSAGE(
-        message.getStr(), res1 == rtl::OUString(str2, str2Len));
+    ASSERT_TRUE(
+        res1 == rtl::OUString(str2, str2Len)) << message.getStr();
     rtl::OUStringBuffer buf2(rtl::OUString(str2, str2Len));
     buf2.insertUtf32(2, 0x10FFFF);
     rtl::OUString res2(buf2.makeStringAndClear());
     createMessage(message, res2, rtl::OUString(str3, str3Len));
-    CPPUNIT_ASSERT_MESSAGE(
-        message.getStr(), res2 == rtl::OUString(str3, str3Len));
+    ASSERT_TRUE(
+        res2 == rtl::OUString(str3, str3Len)) << message.getStr();
 }
+
+} }
+
+
+


Reply via email to