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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri May 21 13:35:12 UTC 2021


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

New commits:
commit 841ee616a5e5d191365c82359943a0171956e03a
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri May 21 12:00:41 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri May 21 15:34:32 2021 +0200

    tdf#126342: sc_ucalc: Add unittest
    
    Change-Id: I81afb8e513821253bc11e07d4bbac3a1abae2f90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115905
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index e98c58a02306..222e3c055358 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -168,6 +168,7 @@ public:
     void testAutoFilterTimeValue();
     void testTdf76441();
     void testTdf142186();
+    void testTdf126342();
     void testAdvancedFilter();
     void testTdf98642();
     void testMergedCells();
@@ -292,6 +293,7 @@ public:
     CPPUNIT_TEST(testAutoFilterTimeValue);
     CPPUNIT_TEST(testTdf76441);
     CPPUNIT_TEST(testTdf142186);
+    CPPUNIT_TEST(testTdf126342);
     CPPUNIT_TEST(testAdvancedFilter);
     CPPUNIT_TEST(testTdf98642);
     CPPUNIT_TEST(testMergedCells);
@@ -3636,6 +3638,37 @@ void Test::testTdf142186()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testTdf126342()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    OUString aCode = "YYYY-MM-DD";
+    sal_Int32 nCheckPos;
+    SvNumFormatType nType;
+    sal_uInt32 nFormat;
+    SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
+    pFormatter->PutEntry( aCode, nCheckPos, nType, nFormat );
+
+    ScPatternAttr aNewAttrs(m_pDoc->GetPool());
+    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), "11/7/19");
+
+    CPPUNIT_ASSERT_EQUAL(OUString("2019-11-07"), m_pDoc->GetString(ScAddress(0,0,0)));
+
+    // Overwrite the existing date with the exact same input
+    m_pDoc->SetString(ScAddress(0,0,0), "11/7/19");
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 2019-11-07
+    // - Actual  : 2011-07-19
+    CPPUNIT_ASSERT_EQUAL(OUString("2019-11-07"), m_pDoc->GetString(ScAddress(0,0,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testAdvancedFilter()
 {
     m_pDoc->InsertTab(0, "Test");


More information about the Libreoffice-commits mailing list