sc/qa/unit/ucalc.cxx |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

New commits:
commit b5ff805386556a01fc7aa39696bfc987739f22b2
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Dec 17 13:37:18 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Dec 17 15:28:29 2024 +0100

    tdf#164124: sc_ucalc: Add unittest
    
    Change-Id: I002369729f8ced8023412d1a57d91816d44dbb3a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178661
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7ef7eb9a3f08..754ad0764749 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3939,6 +3939,32 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf137063)
     m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf164124)
+{
+    m_pDoc->InsertTab(0, u"Test"_ustr);
+
+    OUString aCode = u"YYYY-MM-DD"_ustr;
+    sal_Int32 nCheckPos;
+    SvNumFormatType nType;
+    sal_uInt32 nFormat;
+    SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
+    pFormatter->PutEntry( aCode, nCheckPos, nType, nFormat );
+
+    ScPatternAttr aNewAttrs(m_pDoc->getCellAttributeHelper());
+    SfxItemSet& rSet = aNewAttrs.GetItemSet();
+    rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+    m_pDoc->ApplyPattern(0, 0, 0, aNewAttrs);
+
+    m_pDoc->SetString(ScAddress(0,0,0), u"2021-6/1"_ustr);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 2021-6/1
+    // - Actual  : 1905-07-19
+    CPPUNIT_ASSERT_EQUAL(u"2021-6/1"_ustr, 
m_pDoc->GetString(ScAddress(0,0,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf126342)
 {
     m_pDoc->InsertTab(0, u"Test"_ustr);

Reply via email to