summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorƁukasz Hryniuk <lukasz.hryniuk@wp.pl>2015-08-24 18:06:29 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-26 01:45:25 +0000
commit1a5b5750ed4157420bc0e0e9f384d3984dee9acd (patch)
tree7ea8186f75525f10f9eeb2d0818200d0a8442d22 /sc/qa
parent8e0d49e3b6f6e7146477569e635d2c30863c4cfc (diff)
tdf#89387 test for SUMX2PY2 function
Change-Id: Id407614c75eb04fb920fcf75d368b070323a0b79 Reviewed-on: https://gerrit.libreoffice.org/18003 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.hxx1
-rw-r--r--sc/qa/unit/ucalc_formula.cxx65
2 files changed, 66 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 79d30a97a19c..f10f838b75ac 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -187,6 +187,7 @@ public:
void testFuncFTEST();
void testFuncFTESTBug();
void testFuncCHITEST();
+ void testFuncSUMX2PY2();
void testExternalRef();
void testExternalRefFunctions();
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 90a267ced682..20b9e33c8090 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -5729,5 +5729,70 @@ void Test::testFuncCHITEST()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncSUMX2PY2()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "SumX2PY2 Test");
+
+ OUString aVal;
+ ScAddress aPos(6,0,0);
+ m_pDoc->SetString(aPos, "=SUMX2PY2(A1:C3;D1:F3)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 0.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->SetValue(0, 0, 0, 1.0); // A1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 0.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(3, 0, 0, 2.0); // D1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 5.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(1, 0, 0, 2.0); // B1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 5.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(4, 0, 0, 0.0); // E1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 9.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 0, 0, 3.0); // C1
+ m_pDoc->SetValue(5, 0, 0, 3.0); // F1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 27.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 1, 0, 10.0); // A2
+ m_pDoc->SetValue(3, 1, 0, -10.0); // D2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 227.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 1, 0, -5.0); // C2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 227.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(4, 1, 0, -5.0); // E2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 277.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 1, 0, 0.0); // C2
+ m_pDoc->SetValue(5, 1, 0, 0.0); // F2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 277.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 2, 0, -8.0); // A3
+ m_pDoc->SetValue(3, 2, 0, 8.0); // D3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 405.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(1, 2, 0, 0.0); // B3
+ m_pDoc->SetValue(4, 2, 0, 0.0); // E3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 503.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 2, 0, 1.0); // C3
+ m_pDoc->SetValue(5, 2, 0, 1.0); // F3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 505.0, m_pDoc->GetValue(aPos));
+
+ // add some strings
+ m_pDoc->SetString(4, 1, 0, "a"); // E2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 455.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(1, 1, 0, "a"); // B2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 455.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(0, 0, 0, "a"); // A1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 450.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(3, 0, 0, "a"); // D1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 450.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->SetString(aPos, "=SUMX2PY2({1;2;3};{2;3;4})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2PY2 failed", 43.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMX2PY2({1;2;3};{2;3})");
+ aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUMX2PY2 should return #VALUE! for matrices with different sizes",
+ OUString("#VALUE!"), aVal);
+ m_pDoc->SetString(aPos, "=SUMX2PY2({1;2;3})");
+ aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUMX2PY2 needs two parameters",
+ OUString("Err:511"), aVal);
+
+ m_pDoc->DeleteTab(0);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */