[Libreoffice-commits] core.git: svl/qa

Eike Rathke erack at redhat.com
Fri Feb 16 14:59:54 UTC 2018


 svl/qa/unit/svl.cxx |   57 ++++++++++++++++++++--------------------------------
 1 file changed, 22 insertions(+), 35 deletions(-)

New commits:
commit b809df5d7f82a291356aee147f338cde5579e839
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 16 15:51:59 2018 +0100

    Factor out Spanish "mar" tests to use checkSpecificNumberFormats()
    
    Change-Id: Ie2618ffeea49e45d7bd7d35238a1edbcc5887fa5

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 17b4862c4e6c..b0960e7973fc 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1131,41 +1131,6 @@ void Test::testIsNumberFormat()
         CPPUNIT_ASSERT_EQUAL_MESSAGE(aTests[i].pFormat, aTests[i].bIsNumber, bIsNumber);
 
     }
-
-    // Test Spanish "mar" short name ambiguity, day "martes" or month "marzo".
-    // Day of week names are only parsed away, not evaluated if they actually
-    // correspond to the date given.
-    struct SpanishDate
-    {
-        const char* mpInput;
-        bool mbNumber;
-        const char* mpOutput;
-    } aSpanishTests[] = {
-        { "22/11/1999", true, "22/11/1999" },
-        { "Lun 22/11/1999", true, "22/11/1999" },
-        { "Mar 22/11/1999", true, "22/11/1999" },
-        { "Abr 22/11/1999", false, "" },            // month name AND numeric month don't go along
-        { "Lun Mar 22/11/1999", false, "" },        // month name AND numeric month don't go along
-        { "Mar Mar 22/11/1999", false, "" },        // month name AND numeric month don't go along
-        { "Lun Mar 22 1999", true, "22/03/1999" },
-        { "Mar Mar 22 1999", true, "22/03/1999" },
-        { "Mar Lun 22 1999", false, "" }            // day name only at the beginning (could change?)
-    };
-
-    sal_uInt32 nIndex = aFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SPANISH);
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aSpanishTests); ++i)
-    {
-        double fNumber = 0;
-        OUString aString = OUString::createFromAscii( aSpanishTests[i].mpInput);
-        bool bIsNumber = aFormatter.IsNumberFormat( aString, nIndex, fNumber);
-        CPPUNIT_ASSERT_EQUAL( aSpanishTests[i].mbNumber, bIsNumber);
-        if (aSpanishTests[i].mbNumber)
-        {
-            Color* pColor;
-            aFormatter.GetOutputString( fNumber, nIndex, aString, &pColor);
-            CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aSpanishTests[i].mpOutput), aString);
-        }
-    }
 }
 
 namespace {
@@ -1278,6 +1243,28 @@ void Test::testIsNumberFormatSpecific()
 
         checkSpecificNumberFormats( aFormatter, aIO, "[fr-FR] date");
     }
+
+    {
+        // Test Spanish "mar" short name ambiguity, day "martes" or month "marzo".
+        // Day of week names are only parsed away, not evaluated if they actually
+        // correspond to the date given.
+        SvNumberFormatter aFormatter(m_xContext, LANGUAGE_SPANISH);
+
+        const sal_uInt32 n = aFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SPANISH);
+        std::vector<FormatInputOutput> aIO = {
+            { "22/11/1999", true, "22/11/1999", n },
+            { "Lun 22/11/1999", true, "22/11/1999", n },
+            { "Mar 22/11/1999", true, "22/11/1999", n },
+            { "Abr 22/11/1999", false, "", n },             // month name AND numeric month don't go along
+            { "Lun Mar 22/11/1999", false, "", n },         // month name AND numeric month don't go along
+            { "Mar Mar 22/11/1999", false, "", n },         // month name AND numeric month don't go along
+            { "Lun Mar 22 1999", true, "22/03/1999", n },
+            { "Mar Mar 22 1999", true, "22/03/1999", n },
+            { "Mar Lun 22 1999", false, "", n }             // day name only at the beginning (could change?)
+        };
+
+        checkSpecificNumberFormats( aFormatter, aIO, "[es-ES] date");
+    }
 }
 
 void Test::testUserDefinedNumberFormats()


More information about the Libreoffice-commits mailing list