summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-05-21 00:41:28 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-05-21 09:46:35 +0200
commit2d8f77408ad3b7918096ad2818db266074c66061 (patch)
tree06792c55fabdbfece07d32e8db4026cb80d4a7ac /sc/qa
parentdb8db4732cd50342139c1d2c358a4ce260c4b4f3 (diff)
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@libreoffice.org>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx41
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 43 insertions, 0 deletions
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);