openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1700638 - in /openoffice/trunk/main/sal/qa/rtl/locale: makefile.mk rtl_locale.cxx
Date Tue, 01 Sep 2015 18:40:50 GMT
Author: damjan
Date: Tue Sep  1 18:40:50 2015
New Revision: 1700638

URL: http://svn.apache.org/r1700638
Log:
#i125003# migrate main/sal/qa/rtl/locale from cppunit to Google Test.


Modified:
    openoffice/trunk/main/sal/qa/rtl/locale/makefile.mk
    openoffice/trunk/main/sal/qa/rtl/locale/rtl_locale.cxx

Modified: openoffice/trunk/main/sal/qa/rtl/locale/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/locale/makefile.mk?rev=1700638&r1=1700637&r2=1700638&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/locale/makefile.mk (original)
+++ openoffice/trunk/main/sal/qa/rtl/locale/makefile.mk Tue Sep  1 18:40:50 2015
@@ -31,35 +31,32 @@ 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)
-
 # BEGIN ----------------------------------------------------------------
 # auto generated Target:locale by codegen.pl
-SHL1OBJS=  \
+APP1OBJS=  \
 	$(SLO)$/rtl_locale.obj
 
-SHL1TARGET= rtl_locale
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF=    $(MISC)$/$(SHL1TARGET).def
+APP1TARGET= rtl_locale
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
 
-DEF1NAME    =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
 # auto generated Target:locale
 # 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/rtl/locale/rtl_locale.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/locale/rtl_locale.cxx?rev=1700638&r1=1700637&r2=1700638&view=diff
==============================================================================
--- openoffice/trunk/main/sal/qa/rtl/locale/rtl_locale.cxx (original)
+++ openoffice/trunk/main/sal/qa/rtl/locale/rtl_locale.cxx Tue Sep  1 18:40:50 2015
@@ -26,7 +26,7 @@
 #include "precompiled_sal.hxx"
 // autogenerated file with codegen.pl
 
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
 #include <rtl/locale.hxx>
 #include <osl/thread.h>
 
@@ -38,302 +38,222 @@ namespace rtl_locale
         rtl::OLocale::setDefault(rtl::OUString::createFromAscii("de"), rtl::OUString::createFromAscii("DE"),
/* rtl::OUString() */ rtl::OUString::createFromAscii("hochdeutsch") );
     }
 
-class getDefault : public CppUnit::TestFixture
+class getDefault : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
+    void SetUp()
     {
     }
 
-    void tearDown()
+    void TearDown()
     {
     }
+}; // class getDefault
 
-    // insert your test code here.
-    void getDefault_000()
-    {
-        // this is demonstration code
-        // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
-
-        // due to the fact, we set the default locale at first, this test is no longer possible
-   	// ::rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        // CPPUNIT_ASSERT_MESSAGE("locale must be null", aLocale.getData() == NULL);
-
-    }
-
-    void getDefault_001()
-    {
-        // rtl::OLocale::setDefault(rtl::OUString::createFromAscii("de"), rtl::OUString::createFromAscii("DE"),
rtl::OUString());
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        CPPUNIT_ASSERT_MESSAGE("locale must not null", aLocale.getData() != NULL);
-    }
-
-    // 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.
+TEST_F(getDefault, getDefault_000)
+{
+    // this is demonstration code
+    // ASSERT_TRUE(1 == 1) << "a message";
 
-    CPPUNIT_TEST_SUITE(getDefault);
-    CPPUNIT_TEST(getDefault_000);
-    CPPUNIT_TEST(getDefault_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class getDefault
+    // due to the fact, we set the default locale at first, this test is no longer possible
+    // ::rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    // ASSERT_TRUE(aLocale.getData() == NULL) << "locale must be null";
+}
 
+TEST_F(getDefault, getDefault_001)
+{
+    // rtl::OLocale::setDefault(rtl::OUString::createFromAscii("de"), rtl::OUString::createFromAscii("DE"),
rtl::OUString());
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    ASSERT_TRUE(aLocale.getData() != NULL) << "locale must not be null";
+}
 
-class setDefault : public CppUnit::TestFixture
+class setDefault : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
+    void SetUp()
     {
     }
 
-    void tearDown()
+    void TearDown()
     {
         setDefaultLocale();
     }
+}; // class setDefault
 
-    // insert your test code here.
-    void setDefault_001()
-    {
-        rtl::OLocale::setDefault(rtl::OUString::createFromAscii("en"), rtl::OUString::createFromAscii("US"),
rtl::OUString());
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        CPPUNIT_ASSERT_MESSAGE("locale must not null", aLocale.getData() != NULL);
-
-        // be sure to not GPF
-    }
-
-    // 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.
+TEST_F(setDefault, setDefault_001)
+{
+    rtl::OLocale::setDefault(rtl::OUString::createFromAscii("en"), rtl::OUString::createFromAscii("US"),
rtl::OUString());
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    ASSERT_TRUE(aLocale.getData() != NULL) << "locale must not null";
 
-    CPPUNIT_TEST_SUITE(setDefault);
-    CPPUNIT_TEST(setDefault_001);
-    CPPUNIT_TEST_SUITE_END();
-}; // class setDefault
+    // be sure to not GPF
+}
 
 
-class getLanguage : public CppUnit::TestFixture
+class getLanguage : public ::testing::Test
 {
 public:
-    // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
+    void SetUp()
     {
     }
 
-    // insert your test code here.
-    void getLanguage_001()
-    {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suLanguage = aLocale.getLanguage();
-        t_print("Language: %s\n", rtl::OUStringToOString(suLanguage, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale language must be 'de'", suLanguage.equals(rtl::OUString::createFromAscii("de")));
-    }
-    void getLanguage_002()
+    void TearDown()
     {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suLanguage = rtl_locale_getLanguage(aLocale.getData());
-        t_print("Language: %s\n", rtl::OUStringToOString(suLanguage, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale language must be 'de'", suLanguage.equals(rtl::OUString::createFromAscii("de")));
     }
+}; // class getLanguage
 
-    // 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.
+TEST_F(getLanguage, getLanguage_001)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suLanguage = aLocale.getLanguage();
+    printf("Language: %s\n", rtl::OUStringToOString(suLanguage, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suLanguage.equals(rtl::OUString::createFromAscii("de"))) << "locale
language must be 'de'";
+}
 
-    CPPUNIT_TEST_SUITE(getLanguage);
-    CPPUNIT_TEST(getLanguage_001);
-    CPPUNIT_TEST(getLanguage_002);
-    CPPUNIT_TEST_SUITE_END();
-}; // class getLanguage
+TEST_F(getLanguage, getLanguage_002)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suLanguage = rtl_locale_getLanguage(aLocale.getData());
+    printf("Language: %s\n", rtl::OUStringToOString(suLanguage, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suLanguage.equals(rtl::OUString::createFromAscii("de"))) << "locale
language must be 'de'";
+}
 
 
-class getCountry : public CppUnit::TestFixture
+class getCountry : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
+    void SetUp()
     {
     }
 
-    void tearDown()
-    {
-    }
-
-    // insert your test code here.
-    void getCountry_001()
-    {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suCountry = aLocale.getCountry();
-        t_print("Country: %s\n", rtl::OUStringToOString(suCountry, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale country must be 'DE'", suCountry.equals(rtl::OUString::createFromAscii("DE")));
-    }
-    void getCountry_002()
+    void TearDown()
     {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suCountry = rtl_locale_getCountry(aLocale.getData());
-        t_print("Country: %s\n", rtl::OUStringToOString(suCountry, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale country must be 'DE'", suCountry.equals(rtl::OUString::createFromAscii("DE")));
     }
-
-    // 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(getCountry);
-    CPPUNIT_TEST(getCountry_001);
-    CPPUNIT_TEST(getCountry_002);
-    CPPUNIT_TEST_SUITE_END();
 }; // class getCountry
 
+TEST_F(getCountry, getCountry_001)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suCountry = aLocale.getCountry();
+    printf("Country: %s\n", rtl::OUStringToOString(suCountry, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suCountry.equals(rtl::OUString::createFromAscii("DE"))) << "locale
country must be 'DE'";
+}
 
-class getVariant : public CppUnit::TestFixture
+TEST_F(getCountry, getCountry_002)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suCountry = rtl_locale_getCountry(aLocale.getData());
+    printf("Country: %s\n", rtl::OUStringToOString(suCountry, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suCountry.equals(rtl::OUString::createFromAscii("DE"))) << "locale
country must be 'DE'";
+}
+
+class getVariant : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
+    void SetUp()
     {
     }
 
-    // insert your test code here.
-    void getVariant_001()
+    void TearDown()
     {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suVariant = aLocale.getVariant();
-        t_print("Variant: %s\n", rtl::OUStringToOString(suVariant, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale variant must be 'hochdeutsch'", suVariant.equals(rtl::OUString::createFromAscii("hochdeutsch")));
     }
-    void getVariant_002()
-    {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        rtl::OUString suVariant = rtl_locale_getVariant(aLocale.getData());
-        t_print("Variant: %s\n", rtl::OUStringToOString(suVariant, osl_getThreadTextEncoding()).getStr());
-        CPPUNIT_ASSERT_MESSAGE("locale variant must be 'hochdeutsch'", suVariant.equals(rtl::OUString::createFromAscii("hochdeutsch")));
-    }
-
-    // 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(getVariant);
-    CPPUNIT_TEST(getVariant_001);
-    CPPUNIT_TEST(getVariant_002);
-    CPPUNIT_TEST_SUITE_END();
 }; // class getVariant
 
+TEST_F(getVariant, getVariant_001)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suVariant = aLocale.getVariant();
+    printf("Variant: %s\n", rtl::OUStringToOString(suVariant, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suVariant.equals(rtl::OUString::createFromAscii("hochdeutsch"))) <<
"locale variant must be 'hochdeutsch'";
+}
 
-class hashCode : public CppUnit::TestFixture
+TEST_F(getVariant, getVariant_002)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    rtl::OUString suVariant = rtl_locale_getVariant(aLocale.getData());
+    printf("Variant: %s\n", rtl::OUStringToOString(suVariant, osl_getThreadTextEncoding()).getStr());
+    ASSERT_TRUE(suVariant.equals(rtl::OUString::createFromAscii("hochdeutsch"))) <<
"locale variant must be 'hochdeutsch'";
+}
+
+class hashCode : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
-    {
-    }
-
-    void tearDown()
+    void SetUp()
     {
     }
 
-    // insert your test code here.
-    void hashCode_001()
+    void TearDown()
     {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        sal_Int32 nHashCode = aLocale.hashCode();
-        t_print("Hashcode: %d\n", nHashCode);
-        CPPUNIT_ASSERT_MESSAGE("locale hashcode must be 3831", nHashCode != 0);
     }
-    void hashCode_002()
-    {
-   	rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
-        sal_Int32 nHashCode = rtl_locale_hashCode(aLocale.getData());
-        t_print("Hashcode: %d\n", nHashCode);
-        CPPUNIT_ASSERT_MESSAGE("locale hashcode must be 3831", nHashCode != 0);
-    }
-
-    // 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(hashCode);
-    CPPUNIT_TEST(hashCode_001);
-    CPPUNIT_TEST(hashCode_002);
-    CPPUNIT_TEST_SUITE_END();
 }; // class hashCode
 
+TEST_F(hashCode, hashCode_001)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    sal_Int32 nHashCode = aLocale.hashCode();
+    printf("Hashcode: %d\n", nHashCode);
+    ASSERT_TRUE(nHashCode != 0) << "locale hashcode must be 3831";
+}
+
+TEST_F(hashCode, hashCode_002)
+{
+    rtl::OLocale aLocale = ::rtl::OLocale::getDefault();
+    sal_Int32 nHashCode = rtl_locale_hashCode(aLocale.getData());
+    printf("Hashcode: %d\n", nHashCode);
+    ASSERT_TRUE(nHashCode != 0) << "locale hashcode must be 3831";
+}
 
-class equals : public CppUnit::TestFixture
+class equals : public ::testing::Test
 {
 public:
     // initialise your test code values here.
-    void setUp()
+    void SetUp()
     {
     }
 
-    void tearDown()
+    void TearDown()
     {
     }
+}; // class equals
 
-    // insert your test code here.
-    void equals_001()
-    {
-        rtl::OLocale aLocale1 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"), rtl::OUString());
-        rtl::OLocale aLocale2 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"));
-
-        sal_Bool bLocaleAreEqual = sal_False;
-        bLocaleAreEqual = (aLocale1 == aLocale2);
-
-        CPPUNIT_ASSERT_MESSAGE("check operator ==()", bLocaleAreEqual == sal_True);
-    }
+TEST_F(equals, equals_001)
+{
+    rtl::OLocale aLocale1 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"), rtl::OUString());
+    rtl::OLocale aLocale2 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"));
 
-    void equals_002()
-    {
-        rtl::OLocale aLocale1 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"), rtl::OUString());
-        rtl::OLocale aLocale2 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"));
+    sal_Bool bLocaleAreEqual = sal_False;
+    bLocaleAreEqual = (aLocale1 == aLocale2);
 
-        sal_Int32 nEqual = rtl_locale_equals(aLocale1.getData(), aLocale2.getData());
-        t_print("rtl_locale_equals() result: %d\n", nEqual);
-        CPPUNIT_ASSERT(nEqual != 0);
-    }
+    ASSERT_TRUE(bLocaleAreEqual == sal_True) << "check operator ==()";
+}
 
-    // 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.
+TEST_F(equals, equals_002)
+{
+    rtl::OLocale aLocale1 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"), rtl::OUString());
+    rtl::OLocale aLocale2 = rtl::OLocale::registerLocale(rtl::OUString::createFromAscii("en"),
rtl::OUString::createFromAscii("US"));
 
-    CPPUNIT_TEST_SUITE(equals);
-    CPPUNIT_TEST(equals_001);
-    CPPUNIT_TEST(equals_002);
-    CPPUNIT_TEST_SUITE_END();
-}; // class equals
+    sal_Int32 nEqual = rtl_locale_equals(aLocale1.getData(), aLocale2.getData());
+    printf("rtl_locale_equals() result: %d\n", nEqual);
+    ASSERT_TRUE(nEqual != 0);
+}
 
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::getDefault, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::setDefault, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::getLanguage, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::getCountry, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::getVariant, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::hashCode, "rtl_locale");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_locale::equals, "rtl_locale");
 } // namespace rtl_locale
 
 
 // -----------------------------------------------------------------------------
 
-// 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;
-
-void RegisterAdditionalFunctions(FktRegFuncPtr)
+int main(int argc, char **argv)
 {
     // start message
-    t_print("Initializing ...\n" );
+    printf("Initializing ...\n" );
     rtl_locale::setDefaultLocale();
-    t_print("Initialization Done.\n" );
+    printf("Initialization Done.\n" );
+
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
 }



Mime
View raw message