From 958827673309a80a710a86a9b115945547f520a0 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Sat, 1 Oct 2016 22:44:28 -0400 Subject: tdf#93894: Add unit test for this. Change-Id: Ifd38b9fde776d9be48e776972993856cfe59b477 Reviewed-on: https://gerrit.libreoffice.org/29515 Reviewed-by: Kohei Yoshida Tested-by: Kohei Yoshida --- .../unit/data/ods/shared-formula/column-labels.ods | Bin 0 -> 10129 bytes sc/qa/unit/subsequent_filters-test.cxx | 40 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 sc/qa/unit/data/ods/shared-formula/column-labels.ods diff --git a/sc/qa/unit/data/ods/shared-formula/column-labels.ods b/sc/qa/unit/data/ods/shared-formula/column-labels.ods new file mode 100644 index 000000000000..cfe49ce2c480 Binary files /dev/null and b/sc/qa/unit/data/ods/shared-formula/column-labels.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 8ef4a8c7e7be..f06e66e38489 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -219,6 +219,7 @@ public: void testSharedFormulaBIFF5(); void testSharedFormulaXLSB(); void testSharedFormulaXLS(); + void testSharedFormulaColumnLabelsODS(); void testExternalRefCacheXLSX(); void testExternalRefCacheODS(); void testHybridSharedStringODS(); @@ -329,6 +330,7 @@ public: CPPUNIT_TEST(testSharedFormulaBIFF5); CPPUNIT_TEST(testSharedFormulaXLSB); CPPUNIT_TEST(testSharedFormulaXLS); + CPPUNIT_TEST(testSharedFormulaColumnLabelsODS); CPPUNIT_TEST(testExternalRefCacheXLSX); CPPUNIT_TEST(testExternalRefCacheODS); CPPUNIT_TEST(testHybridSharedStringODS); @@ -3320,6 +3322,44 @@ void ScFiltersTest::testSharedFormulaXLS() } } +void ScFiltersTest::testSharedFormulaColumnLabelsODS() +{ + ScDocShellRef xDocSh = loadDoc("shared-formula/column-labels.", FORMAT_ODS); + + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument& rDoc = xDocSh->GetDocument(); + rDoc.CalcAll(); + + // Cells C2, D2 and E2 all should contain formula groups of length 5. + for (SCCOL i = 2; i <= 4; ++i) + { + const ScFormulaCell* pCell = rDoc.GetFormulaCell(ScAddress(i,1,0)); + CPPUNIT_ASSERT(pCell); + CPPUNIT_ASSERT(pCell->IsShared()); + CPPUNIT_ASSERT_EQUAL(static_cast(5), pCell->GetSharedLength()); + } + + CPPUNIT_ASSERT_EQUAL( 5.0, rDoc.GetValue(ScAddress(2,1,0))); + CPPUNIT_ASSERT_EQUAL(15.0, rDoc.GetValue(ScAddress(2,2,0))); + CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(2,3,0))); + CPPUNIT_ASSERT_EQUAL(28.0, rDoc.GetValue(ScAddress(2,4,0))); + CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(2,5,0))); + + CPPUNIT_ASSERT_EQUAL( 0.0, rDoc.GetValue(ScAddress(3,1,0))); + CPPUNIT_ASSERT_EQUAL( 50.0, rDoc.GetValue(ScAddress(3,2,0))); + CPPUNIT_ASSERT_EQUAL(144.0, rDoc.GetValue(ScAddress(3,3,0))); + CPPUNIT_ASSERT_EQUAL(147.0, rDoc.GetValue(ScAddress(3,4,0))); + CPPUNIT_ASSERT_EQUAL(320.0, rDoc.GetValue(ScAddress(3,5,0))); + + CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(4,1,0))); + CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(4,2,0))); + CPPUNIT_ASSERT_EQUAL(4.0, rDoc.GetValue(ScAddress(4,3,0))); + CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(4,4,0))); + CPPUNIT_ASSERT_EQUAL(5.0, rDoc.GetValue(ScAddress(4,5,0))); + + xDocSh->DoClose(); +} + void ScFiltersTest::testExternalRefCacheXLSX() { ScDocShellRef xDocSh = loadDoc("external-refs.", FORMAT_XLSX); -- cgit