summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-05-20 21:29:30 +0200
committerEike Rathke <erack@redhat.com>2017-05-22 11:00:56 +0200
commit1e70dedee1c7be912e4aaa2ff12b046dbd364a86 (patch)
treea219c934d432e5cd16841d735759ed74c0ff9f8f
parentd9ba325bf1fd4e8f5557f34e5af6502107be5207 (diff)
Add unit test for SUBTOTAL over reference list in array context, tdf#58874
Change-Id: I82752c035f6551d3136dc06331ff8745ba959463
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx27
2 files changed, 29 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 5d1def66c7c7..d36ed7ddd2a5 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 testFuncRefListArraySUBTOTAL();
void testMatConcat();
void testMatConcatReplication();
void testRefR1C1WholeCol();
@@ -620,6 +621,7 @@ public:
CPPUNIT_TEST(testFuncLCM);
CPPUNIT_TEST(testFuncSUMSQ);
CPPUNIT_TEST(testFuncMDETERM);
+ CPPUNIT_TEST(testFuncRefListArraySUBTOTAL);
CPPUNIT_TEST(testMatConcat);
CPPUNIT_TEST(testMatConcatReplication);
CPPUNIT_TEST(testExternalRef);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 7c58bcb51522..c2b46cec85ae 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7904,4 +7904,31 @@ void Test::testFuncRowsHidden()
m_pDoc->DeleteTab(0);
}
+// Test SUBTOTAL with reference lists in array context.
+void Test::testFuncRefListArraySUBTOTAL()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+ m_pDoc->InsertTab(0, "Test");
+
+ m_pDoc->SetValue(0,0,0, 1.0); // A1
+ m_pDoc->SetValue(0,1,0, 2.0); // A2
+ m_pDoc->SetValue(0,2,0, 4.0); // A3
+ m_pDoc->SetValue(0,3,0, 8.0); // A4
+ m_pDoc->SetValue(0,4,0, 16.0); // A5
+ m_pDoc->SetValue(0,5,0, 32.0); // A6
+
+ // Matrix in B7:B9, individual SUM of A2:A3, A3:A4 and A4:A5
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ m_pDoc->InsertMatrixFormula(1, 6, 1, 8, aMark, "=SUBTOTAL(9;OFFSET(A1;ROW(1:3);0;2))");
+ ScAddress aPos(1,6,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL for A2:A3 failed", 6.0, m_pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL for A3:A4 failed", 12.0, m_pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL for A4:A5 failed", 24.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */