[Libreoffice-commits] core.git: sc/qa
Łukasz Hryniuk
lukasz.hryniuk at wp.pl
Tue Aug 25 18:45:46 PDT 2015
sc/qa/unit/ucalc.hxx | 1
sc/qa/unit/ucalc_formula.cxx | 65 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
New commits:
commit 1a5b5750ed4157420bc0e0e9f384d3984dee9acd
Author: Łukasz Hryniuk <lukasz.hryniuk at wp.pl>
Date: Mon Aug 24 18:06:29 2015 +0200
tdf#89387 test for SUMX2PY2 function
Change-Id: Id407614c75eb04fb920fcf75d368b070323a0b79
Reviewed-on: https://gerrit.libreoffice.org/18003
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 79d30a9..f10f838 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 90a267c..20b9e33 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: */
More information about the Libreoffice-commits
mailing list