[Libreoffice-commits] core.git: sc/qa
Łukasz Hryniuk
lukasz.hryniuk at wp.pl
Thu Sep 24 14:15:04 PDT 2015
sc/qa/unit/ucalc.hxx | 2 +
sc/qa/unit/ucalc_formula.cxx | 66 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
New commits:
commit 8c7ba16ba4bdedb4354f342b20d5a5de8a132b48
Author: Łukasz Hryniuk <lukasz.hryniuk at wp.pl>
Date: Tue Sep 22 16:43:40 2015 +0200
Test for SUMSQ
Change-Id: I077df1d8941fdee2722ab2112f09667fc8369402
Reviewed-on: https://gerrit.libreoffice.org/18764
Reviewed-by: Łukasz Hryniuk <lukasz.hryniuk at wp.pl>
Tested-by: Łukasz Hryniuk <lukasz.hryniuk at wp.pl>
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index bdd12d5..37e4433 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -190,6 +190,7 @@ public:
void testFuncSUMX2PY2();
void testFuncGCD();
void testFuncLCM();
+ void testFuncSUMSQ();
void testExternalRef();
void testExternalRefFunctions();
@@ -526,6 +527,7 @@ public:
CPPUNIT_TEST(testFuncSUMX2PY2);
CPPUNIT_TEST(testFuncGCD);
CPPUNIT_TEST(testFuncLCM);
+ CPPUNIT_TEST(testFuncSUMSQ);
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testExternalRefFunctions);
CPPUNIT_TEST(testCopyToDocument);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 744c583..8a1ebd7 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -6217,4 +6217,70 @@ void Test::testFuncLCM()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncSUMSQ()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "SUMSQTest");
+
+ ScAddress aPos(4,0,0);
+
+ m_pDoc->SetString(aPos, "=SUMSQ(A1)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 0.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 0, 0, 1.0); // A1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 1.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 0, 0, -1.0); // A1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 1.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 1, 0, -2.0); // A2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 1.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->SetString(aPos, "=SUMSQ(A1:A3)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 5.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(1, 0, 0, 3.0); // B1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 5.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ(A1:C3)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 14.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(1, 1, 0, -4.0); // B2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 30.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(1, 2, 0, "a"); // B3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 30.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(1, 2, 0, 0.0); // B3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 30.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(0, 2, 0, 6.0); // A3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 66.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 0, 0, -5.0); // C1
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 91.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 1, 0, 3.0); // C2
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 100.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetValue(2, 2, 0, 2.0); // C3
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ with a string for failed", 104.0, m_pDoc->GetValue(aPos));
+
+ // inline array
+ m_pDoc->SetString(aPos, "=SUMSQ({1;2;3})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 14.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ({3;6;9})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 126.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ({15;0})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 225.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ({-3;3;1})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 19.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ({\"a\";-4;-5})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 41.0, m_pDoc->GetValue(aPos));
+
+ m_pDoc->SetString(aPos, "=SUMSQ(4;1;-3)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 26.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ(0;5;13;-7;-4)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 259.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ(0;12;24;36;48;60)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 7920.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ(0;-12;-24;36;-48;60)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 7920.0, m_pDoc->GetValue(aPos));
+ m_pDoc->SetString(aPos, "=SUMSQ(\"a\";1;\"d\";-4;2)");
+ OUString aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SUMSQ should return #VALUE! for a array with strings",
+ OUString("#VALUE!"), aVal);
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list