summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-09 11:10:34 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-09 11:35:50 -0500
commit71fe47cfe652829ff7dc09ae49b1c6c22d9b6a6d (patch)
tree7c7c80dd7f2b8789b17baad051dcb53106ad4602
parenta6b41b0c1460d3c9516b8d4e4d88abdc4fdb7ea2 (diff)
fdo#74479: Test case for SUMPRODUCT.
Change-Id: I2e8669c1cd6c824751d557c7c9ee735d580f17e9
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx25
2 files changed, 27 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 053e60709326..a32b04825568 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -115,6 +115,7 @@ public:
void testFuncROW();
void testFuncSUM();
void testFuncPRODUCT();
+ void testFuncSUMPRODUCT();
void testFuncN();
void testFuncCOUNTIF();
void testFuncNUMBERVALUE();
@@ -347,6 +348,7 @@ public:
CPPUNIT_TEST(testFuncROW);
CPPUNIT_TEST(testFuncSUM);
CPPUNIT_TEST(testFuncPRODUCT);
+ CPPUNIT_TEST(testFuncSUMPRODUCT);
CPPUNIT_TEST(testFuncN);
CPPUNIT_TEST(testFuncCOUNTIF);
CPPUNIT_TEST(testFuncNUMBERVALUE);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 05ff6b6bd87e..a4b628953859 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1790,6 +1790,31 @@ void Test::testFuncPRODUCT()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncSUMPRODUCT()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
+ ScAddress aPos(0,0,0);
+ m_pDoc->SetString(aPos, "=SUMPRODUCT(B1:B3;C1:C3)");
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(2,0,0), 1.0); // C1
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(1,0,0), 1.0); // B1
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(1,1,0), 2.0); // B2
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(2,1,0), 3.0); // C2
+ CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(2,2,0), -2.0); // C3
+ CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(ScAddress(1,2,0), 5.0); // B3
+ CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncN()
{
OUString aTabName("foo");