Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2784

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/84/2784/1

unit test for fdo#60915

Change-Id: Ib7c1e87521fbbfd76b8eeead17c58915c5d71728
---
M svl/qa/unit/svl.cxx
1 file changed, 61 insertions(+), 0 deletions(-)



diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 805992e..26a0b8d 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -86,13 +86,20 @@
     virtual void tearDown();
 
     void testNumberFormat();
+    void testFdo60915();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testNumberFormat);
+    CPPUNIT_TEST(testFdo60915);
     CPPUNIT_TEST_SUITE_END();
 
 private:
     uno::Reference< uno::XComponentContext > m_xContext;
+    void checkPreviewString(SvNumberFormatter& aFormatter,
+                            const OUString& sCode,
+                            double fPreviewNumber,
+                            LanguageType eLang,
+                            OUString& sExpected);
 };
 
 Test::Test()
@@ -300,6 +307,60 @@
     }
 }
 
+void Test::checkPreviewString(SvNumberFormatter& aFormatter,
+                              const OUString& sCode,
+                              double fPreviewNumber,
+                              LanguageType eLang,
+                              OUString& sExpected)
+{
+    OUString sStr;
+    Color* pColor = 0;
+    Color** ppColor = &pColor;
+    if (!aFormatter.GetPreviewString(sCode, fPreviewNumber, sStr, ppColor, eLang))
+        CPPUNIT_FAIL("GetPreviewString() failed");
+    CPPUNIT_ASSERT_EQUAL(sExpected, sStr);
+}
+
+void Test::testFdo60915()
+{
+    LanguageType eLang = LANGUAGE_THAI;
+    OUString sCode, sExpected;
+    double fPreviewNumber = 1234; // equals 18/05/1903 (2446 B.E.)
+    SvNumberFormatter aFormatter(m_xContext, eLang);
+    {
+        sCode = "[~buddhist]D/MM/YYYY";
+        sExpected = "18/05/2446";
+        checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+    }
+    {
+        sCode = "[~buddhist]D/MM/YY";
+        sExpected = "18/05/46";
+        checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+    }
+    {
+        sCode = "[NatNum1][$-41E][~buddhist]D/MM/YYYY";
+        sal_Unicode sTemp[] =
+        {
+            0x0E51, 0x0E58, 0x002F,
+            0x0E50, 0x0E55, 0x002F,
+            0x0E52, 0x0E54, 0x0E54, 0x0E56
+        };
+        sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp));
+        checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+    }
+    {
+        sCode = "[NatNum1][$-41E][~buddhist]D/MM/YY";
+        sal_Unicode sTemp[] =
+        {
+            0x0E51, 0x0E58, 0x002F,
+            0x0E50, 0x0E55, 0x002F,
+            0x0E54, 0x0E56
+        };
+        sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp));
+        checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }

-- 
To view, visit https://gerrit.libreoffice.org/2784
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7c1e87521fbbfd76b8eeead17c58915c5d71728
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Korrawit Pruegsanusak <detective.conan.1412@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.