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

Eike Rathke erack at redhat.com
Wed Dec 13 17:02:17 UTC 2017


 svl/qa/unit/svl.cxx |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit e3cc0ebafa40d1aa55f3603cb89fa9c6c67a855b
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Dec 13 17:57:47 2017 +0100

    Unit test testUserDefinedNumberFormats()
    
    Change-Id: Ic908af0bf5cbd83fab7bbf2d2f37a1b51bc5e32a

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 558047bec5a2..7ff1d23dcca8 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -67,6 +67,7 @@ public:
     void testUserDefinedNumberFormats();
     void testNfEnglishKeywordsIntegrity();
     void testStandardColorIntegrity();
+    void testColorNamesConversion();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testNumberFormat);
@@ -81,6 +82,7 @@ public:
     CPPUNIT_TEST(testUserDefinedNumberFormats);
     CPPUNIT_TEST(testNfEnglishKeywordsIntegrity);
     CPPUNIT_TEST(testStandardColorIntegrity);
+    CPPUNIT_TEST(testColorNamesConversion);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1475,6 +1477,41 @@ void Test::testStandardColorIntegrity()
     CPPUNIT_ASSERT_EQUAL( aStandardColors[9].GetColor(), COL_WHITE );
 }
 
+void Test::testColorNamesConversion()
+{
+    SvNumberFormatter aFormatter(m_xContext, LANGUAGE_GERMAN);
+    const SvNumberformat* pNumberFormat = aFormatter.GetEntry(0);
+    const ::std::vector<OUString> & rEnglishKeywords = pNumberFormat->GetEnglishKeywords();
+    const NfKeywordTable& rKeywords = pNumberFormat->GetKeywords();
+
+    // Holding a reference to the NfKeywordTable doesn't help if we switch
+    // locales internally, so copy the relevant parts in advance.
+    std::vector<OUString> aGermanKeywords(NF_KEYWORD_ENTRIES_COUNT);
+    for (size_t i = NF_KEY_COLOR; i <= NF_KEY_WHITE; ++i)
+        aGermanKeywords[i] = rKeywords[i];
+
+    // Check that we actually have German and English keywords.
+    CPPUNIT_ASSERT_EQUAL( OUString("FARBE"), aGermanKeywords[NF_KEY_COLOR]);
+    CPPUNIT_ASSERT_EQUAL( OUString("COLOR"), rEnglishKeywords[NF_KEY_COLOR]);
+
+    // Test each color conversion.
+    // [FARBE1] -> [COLOR1] can't be tested because we have no color table link
+    // set, so the scanner returns nCheckPos error.
+    sal_Int32 nCheckPos;
+    short nType;
+    sal_uInt32 nKey;
+    OUString aFormatCode;
+
+    for (size_t i = NF_KEY_BLACK; i <= NF_KEY_WHITE; ++i)
+    {
+        aFormatCode = "[" + aGermanKeywords[i] + "]0";
+        aFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType, nKey, LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", 0, nCheckPos);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Type should be NUMBER.", css::util::NumberFormat::NUMBER, nType);
+        CPPUNIT_ASSERT_EQUAL( OUString("[" + rEnglishKeywords[i] + "]0"), aFormatCode);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }


More information about the Libreoffice-commits mailing list