summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-06-09 14:10:34 +0200
committerEike Rathke <erack@redhat.com>2017-06-09 14:11:13 +0200
commitf59e802478e35e7b6f561f24806bca47b604529b (patch)
tree5adac493c42bc7b78c04bd497d3c570b9c6085b3 /sc
parente78d128e3b7bf45990d1f7b27123ccd616665f93 (diff)
Add unit test for SUMIFS in array context
Change-Id: I5318ab8bb4d896f3c936ec8d04eba3908b59861a
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx41
2 files changed, 43 insertions, 0 deletions
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()
{