diff options
author | Eike Rathke <erack@redhat.com> | 2019-11-08 01:52:44 +0100 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2019-11-08 09:39:20 +0100 |
commit | 3e71ec4dd593d4c7d904a8617be5808a0c0f02b1 (patch) | |
tree | 60eb3e4c24cc8c97f1335f087988be91371207fc /svl | |
parent | 3b49477c31692730f15dc571c823515889ccaec9 (diff) |
Unit test for fixed locale Excel export formats, tdf#128649
Change-Id: I7ec63659c39acb612de4df502e364afdc2cc7189
Reviewed-on: https://gerrit.libreoffice.org/82257
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 17035f29dc86..d30a7b6279ec 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -70,6 +70,7 @@ public: void testNfEnglishKeywordsIntegrity(); void testStandardColorIntegrity(); void testColorNamesConversion(); + void testExcelExportFormats(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testNumberFormat); @@ -86,6 +87,7 @@ public: CPPUNIT_TEST(testNfEnglishKeywordsIntegrity); CPPUNIT_TEST(testStandardColorIntegrity); CPPUNIT_TEST(testColorNamesConversion); + CPPUNIT_TEST(testExcelExportFormats); CPPUNIT_TEST_SUITE_END(); private: @@ -1687,6 +1689,45 @@ void Test::testColorNamesConversion() } } +void Test::testExcelExportFormats() +{ + // Create a formatter with "system" locale other than the specific formats' + // locale, and different from the en-US export locale. + SvNumberFormatter aFormatter( m_xContext, LANGUAGE_ENGLISH_UK); + + OUString aCode; + sal_Int32 nCheckPos; + SvNumFormatType eType; + sal_uInt32 nKey1, nKey2; + + aCode = "00.00"; + aFormatter.PutandConvertEntry( aCode, nCheckPos, eType, nKey1, + LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH_SAFRICA, false); + CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos); + CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.", + nKey1 > SV_COUNTRY_LANGUAGE_OFFSET); + + aCode = "[$R-1C09] #,##0.0;[$R-1C09]-#,##0.0"; + aFormatter.PutandConvertEntry( aCode, nCheckPos, eType, nKey2, + LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH_SAFRICA, false); + CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos); + CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.", + nKey2 > SV_COUNTRY_LANGUAGE_OFFSET); + + // The export formatter. + SvNumberFormatter aTempFormatter( m_xContext, LANGUAGE_ENGLISH_US); + NfKeywordTable aKeywords; + aTempFormatter.FillKeywordTableForExcel( aKeywords); + + aCode = aFormatter.GetFormatStringForExcel( nKey1, aKeywords, aTempFormatter); + // Test that LCID is prepended. + CPPUNIT_ASSERT_EQUAL( OUString("[$-1C09]00.00"), aCode); + + aCode = aFormatter.GetFormatStringForExcel( nKey2, aKeywords, aTempFormatter); + // Test that LCID is not prepended. Note that literal characters are escaped. + CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |