sc/qa/unit/ucalc.cxx | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 3 ++ 2 files changed, 55 insertions(+)
New commits: commit 5fea81e4bfc2372563c0612f95406ca34fdd2c96 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Sat Feb 11 15:58:23 2017 -0500 tdf#86470: add unit test for this. Change-Id: Ib93703d10fe1fff0898bc935222df7a0cfe20486 Reviewed-on: https://gerrit.libreoffice.org/34160 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Kohei Yoshida <libreoff...@kohei.us> diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 86f04c4..884ae3f 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -710,6 +710,58 @@ void Test::testSelectionFunction() m_pDoc->DeleteTab(0); } +void Test::testMarkedCellIteration() +{ + m_pDoc->InsertTab(0, "Test"); + + // Insert cells to A1, A5, B2 and C3. + m_pDoc->SetString(ScAddress(0,0,0), "California"); + m_pDoc->SetValue(ScAddress(0,4,0), 1.2); + m_pDoc->SetEditText(ScAddress(1,1,0), "Boston"); + m_pDoc->SetFormula(ScAddress(2,2,0), "=SUM(1,2,3)", m_pDoc->GetGrammar()); + + // Select A1:C5. + ScMarkData aMarkData; + aMarkData.SetMarkArea(ScRange(0,0,0,2,4,0)); + aMarkData.MarkToMulti(); // TODO : we shouldn't have to do this. + + struct Check + { + SCCOL mnCol; + SCROW mnRow; + }; + + const std::vector<Check> aChecks = { + { 0, 0 }, // A1 + { 0, 4 }, // A5 + { 1, 1 }, // B2 + { 2, 2 }, // C3 + }; + + SCROW nRow = -1; // Start from the imaginary row before A1. + SCCOL nCol = 0; + + for (const Check& rCheck : aChecks) + { + bool bFound = m_pDoc->GetNextMarkedCell(nCol, nRow, 0, aMarkData); + if (!bFound) + { + std::ostringstream os; + os << ScAddress(rCheck.mnCol, rCheck.mnRow, 0).GetColRowString() << " was expected, but not found."; + CPPUNIT_FAIL(os.str().data()); + } + + CPPUNIT_ASSERT_EQUAL(rCheck.mnRow, nRow); + CPPUNIT_ASSERT_EQUAL(rCheck.mnCol, nCol); + } + + // No more marked cells on this sheet. + bool bFound = m_pDoc->GetNextMarkedCell(nCol, nRow, 0, aMarkData); + CPPUNIT_ASSERT(!bFound); + + m_pDoc->DeleteTab(0); +} + void Test::testCopyToDocument() { CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "src")); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index fc956db..1715447 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -123,6 +123,8 @@ public: */ void testSelectionFunction(); + void testMarkedCellIteration(); + void testFormulaCreateStringFromTokens(); void testFormulaParseReference(); void testFetchVectorRefArray(); @@ -502,6 +504,7 @@ public: CPPUNIT_TEST(testRowForHeight); CPPUNIT_TEST(testDataEntries); CPPUNIT_TEST(testSelectionFunction); + CPPUNIT_TEST(testMarkedCellIteration); CPPUNIT_TEST(testFormulaCreateStringFromTokens); CPPUNIT_TEST(testFormulaParseReference); CPPUNIT_TEST(testFetchVectorRefArray); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits