tdf#76836: sc_ucalc: Add unittest
Change-Id: I62d4325dcaee19188529bb749801dc945c060572
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125487
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index cc101bf..32a53aa 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -169,6 +169,7 @@ public:
void testDataArea();
void testAutofilter();
void testAutoFilterTimeValue();
void testTdf76836();
void testTdf76441();
void testTdf142186();
void testTdf137063();
@@ -292,6 +293,7 @@ public:
CPPUNIT_TEST(testToggleRefFlag);
CPPUNIT_TEST(testAutofilter);
CPPUNIT_TEST(testAutoFilterTimeValue);
CPPUNIT_TEST(testTdf76836);
CPPUNIT_TEST(testTdf76441);
CPPUNIT_TEST(testTdf142186);
CPPUNIT_TEST(testTdf137063);
@@ -3579,6 +3581,36 @@ void Test::testTdf76441()
m_pDoc->DeleteTab(0);
}
void Test::testTdf76836()
{
m_pDoc->InsertTab(0, "Test");
OUString aCode = "\"192.168.0.\"@";
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->SetValue(0,0,0, 10.0);
// Without the fix in place, this test would have failed with
// - Expected: 10
// - Actual : 192.168.0.10
CPPUNIT_ASSERT_EQUAL(OUString("10"), m_pDoc->GetString(ScAddress(0,0,0)));
m_pDoc->ApplyPattern(0, 1, 0, aNewAttrs);
m_pDoc->SetString(ScAddress(0,1,0), "10");
CPPUNIT_ASSERT_EQUAL(OUString("192.168.0.10"), m_pDoc->GetString(ScAddress(0,1,0)));
m_pDoc->DeleteTab(0);
}
void Test::testTdf142186()
{
m_pDoc->InsertTab(0, "Test");