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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri May 21 07:47:14 UTC 2021


 sc/qa/unit/ucalc.cxx |   41 +++++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx |    2 ++
 2 files changed, 43 insertions(+)

New commits:
commit 2d8f77408ad3b7918096ad2818db266074c66061
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri May 21 00:41:28 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri May 21 09:46:35 2021 +0200

    tdf#76441: sc_ucalc: Add unittest
    
    Change-Id: I39743a3d5100dd598e8af94c2bdd61b03dc68e57
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115894
    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 ae37d3007981..278062d59a3e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3312,6 +3312,47 @@ void Test::testAutoFilterTimeValue()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testTdf76441()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    // The result will be different depending on whether the format is set before
+    // or after inserting the string
+
+    OUString aCode = "MM:SS";
+    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));
+    {
+        // First insert the string, then the format
+        m_pDoc->SetString(ScAddress(0,0,0), "01:20");
+
+        m_pDoc->ApplyPattern(0, 0, 0, aNewAttrs);
+
+        CPPUNIT_ASSERT_EQUAL(OUString("20:00"), m_pDoc->GetString(ScAddress(0,0,0)));
+    }
+
+    {
+        // First set the format, then insert the string
+        m_pDoc->ApplyPattern(0, 1, 0, aNewAttrs);
+
+        m_pDoc->SetString(ScAddress(0,1,0), "01:20");
+
+        // Without the fix in place, this test would have failed with
+        // - Expected: 01:20
+        // - Actual  : 20:00
+        CPPUNIT_ASSERT_EQUAL(OUString("01:20"), m_pDoc->GetString(ScAddress(0,1,0)));
+    }
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testAdvancedFilter()
 {
     m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 5d272430f88c..1047dca5cc81 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -92,6 +92,7 @@ public:
     void testDataArea();
     void testAutofilter();
     void testAutoFilterTimeValue();
+    void testTdf76441();
     void testAdvancedFilter();
     void testTdf98642();
     void testMergedCells();
@@ -214,6 +215,7 @@ public:
     CPPUNIT_TEST(testToggleRefFlag);
     CPPUNIT_TEST(testAutofilter);
     CPPUNIT_TEST(testAutoFilterTimeValue);
+    CPPUNIT_TEST(testTdf76441);
     CPPUNIT_TEST(testAdvancedFilter);
     CPPUNIT_TEST(testTdf98642);
     CPPUNIT_TEST(testMergedCells);


More information about the Libreoffice-commits mailing list