sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_formula.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
New commits: commit f59e802478e35e7b6f561f24806bca47b604529b Author: Eike Rathke <er...@redhat.com> Date: Fri Jun 9 14:10:34 2017 +0200 Add unit test for SUMIFS in array context Change-Id: I5318ab8bb4d896f3c936ec8d04eba3908b59861a diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index d36ed7ddd2a5..dac42e64b77b 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -212,6 +212,7 @@ public: void testFuncLCM(); void testFuncSUMSQ(); void testFuncMDETERM(); + void testFuncSUMIFS(); void testFuncRefListArraySUBTOTAL(); void testMatConcat(); void testMatConcatReplication(); @@ -621,6 +622,7 @@ public: CPPUNIT_TEST(testFuncLCM); CPPUNIT_TEST(testFuncSUMSQ); CPPUNIT_TEST(testFuncMDETERM); + CPPUNIT_TEST(testFuncSUMIFS); CPPUNIT_TEST(testFuncRefListArraySUBTOTAL); CPPUNIT_TEST(testMatConcat); CPPUNIT_TEST(testMatConcatReplication); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 312ac3328a9e..7fa90babca6c 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -7904,6 +7904,47 @@ void Test::testFuncRowsHidden() m_pDoc->DeleteTab(0); } +// Test SUMIFS in array context. +void Test::testFuncSUMIFS() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + m_pDoc->InsertTab(0, "Test"); + + // Data in A1:B7, query in A9:A11 + std::vector<std::vector<const char*>> aData = { + { "a", "1" }, + { "b", "2" }, + { "c", "4" }, + { "d", "8" }, + { "a", "16" }, + { "b", "32" }, + { "c", "64" }, + {}, + { "a" }, + { "b" }, + { "c" }, + }; + + insertRangeData(m_pDoc, ScAddress(0,0,0), aData); + + ScMarkData aMark; + aMark.SelectOneTable(0); + // Matrix formula in C8:C10 + m_pDoc->InsertMatrixFormula(2, 7, 2, 9, aMark, "=SUMIFS(B1:B7;A1:A7;A9:A11)"); + + // Result B1+B5, B2+B6, B3+B7 + std::vector<std::vector<const char*>> aCheck = { + { "17" }, + { "34" }, + { "68" } + }; + + bool bGood = checkOutput(m_pDoc, ScRange(2,7,0, 2,9,0), aCheck, "SUMIFS in array context"); + CPPUNIT_ASSERT(bGood); + + m_pDoc->DeleteTab(0); +} + // Test SUBTOTAL with reference lists in array context. void Test::testFuncRefListArraySUBTOTAL() { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits