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

New commits:
commit c712dd24410e49da4039e4e5bec536d673544b90
Author:     David Hashe <m...@dhashe.com>
AuthorDate: Fri Mar 14 18:31:42 2025 -0400
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Apr 30 11:01:41 2025 +0200

    tdf#39749 Add calc unit test covering tdf#147265
    
    Change-Id: I5838f87c7e21a6dc167d49d8680e39dd219d28f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182976
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index e2969c996d75..c3401be40dbb 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -2033,6 +2033,33 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf160306)
     CPPUNIT_ASSERT_EQUAL(u"57.38"_ustr, output);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf147265)
+{
+    SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US);
+    bool bBanking = true;
+    const NfCurrencyEntry& rCurrencyEntryUS
+        = SvNumberFormatter::GetCurrencyEntry(LANGUAGE_ENGLISH_US);
+    const NfCurrencyEntry& rCurrencyEntryCAN
+        = SvNumberFormatter::GetCurrencyEntry(LANGUAGE_ENGLISH_CAN);
+
+    // Add US formats, and then Canadian formats, and then US formats again.
+    // The default for the US format should stay the same.
+    NfWSStringsDtor aWSStringsDtor;
+    sal_uInt16 nDefault1
+        = aFormatter.GetCurrencyFormatStrings(aWSStringsDtor, 
rCurrencyEntryUS, bBanking);
+    aFormatter.GetCurrencyFormatStrings(aWSStringsDtor, rCurrencyEntryCAN, 
bBanking);
+    sal_uInt16 nDefault2
+        = aFormatter.GetCurrencyFormatStrings(aWSStringsDtor, 
rCurrencyEntryUS, bBanking);
+
+    // Without the fix, we always returned the final element of the array, 
because we add the
+    // element that should be the default last. However, if we try to add an 
element that is
+    // already present in the array, then we don't add it, so the final 
element of the array
+    // isn't necessarily the default. In this case, the final element would 
actually be the
+    // Canadian default format, which is a different index in the array from 
the American
+    // default format.
+    CPPUNIT_ASSERT_EQUAL(nDefault1, nDefault2);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }

Reply via email to