sc/qa/unit/ucalc.cxx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
New commits: commit 841ee616a5e5d191365c82359943a0171956e03a Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri May 21 12:00:41 2021 +0200 Commit: Xisco Fauli <xiscofa...@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 <xiscofa...@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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits