tdf#98844: sc: Add unittest

Change-Id: I31fc5ca3778048010e34dafd289e0cadf7ee4169
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97347
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/data/ods/tdf98844.ods b/sc/qa/unit/data/ods/tdf98844.ods
new file mode 100644
index 0000000..1e072b7
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf98844.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 0cb013d..71d0d22 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -226,6 +226,7 @@ public:
    void testBnc762542();

    void testTdf103734();
    void testTdf98844();
    void testTdf100458();
    void testTdf127982();
    void testTdf100709XLSX();
@@ -382,6 +383,7 @@ public:
    CPPUNIT_TEST(testHiddenSheetsXLSX);

    CPPUNIT_TEST(testTdf103734);
    CPPUNIT_TEST(testTdf98844);
    CPPUNIT_TEST(testTdf100458);
    CPPUNIT_TEST(testTdf127982);
    CPPUNIT_TEST(testTdf100709XLSX);
@@ -3744,6 +3746,25 @@ void ScFiltersTest::testTdf103734()
    xDocSh->DoClose();
}

void ScFiltersTest::testTdf98844()
{
    ScDocShellRef xDocSh = loadDoc("tdf98844.", FORMAT_ODS);
    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
    ScDocument& rDoc = xDocSh->GetDocument();

    CPPUNIT_ASSERT_EQUAL(47.6227, rDoc.GetValue(ScAddress(0,7,0)));
    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0,8,0)));

    xDocSh->DoHardRecalc();

    // Without the fix in place, SUM() wouldn't have been updated when
    // Precision as shown is enabled
    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0,7,0)));
    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0,8,0)));

    xDocSh->DoClose();
}

void ScFiltersTest::testTdf100458()
{
    ScDocShellRef xDocSh = loadDoc("tdf100458_lost_zero_value.", FORMAT_ODS);