[Libreoffice-commits] .: Branch 'libreoffice-3-4' - sc/qa

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Apr 14 19:48:09 PDT 2011


 sc/qa/unit/ucalc.cxx |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit fe8e63ab25a53799fe79a89ee865f03fe2fdf45d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Apr 14 22:46:33 2011 -0400

    New test for function evaluation with missing parameters.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b489528..4c224e3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -225,6 +225,7 @@ public:
     void testInput();
     void testSUM();
     void testVolatileFunc();
+    void testFuncParam();
     void testNamedRange();
     void testCSV();
     void testMatrix();
@@ -256,6 +257,7 @@ public:
     CPPUNIT_TEST(testInput);
     CPPUNIT_TEST(testSUM);
     CPPUNIT_TEST(testVolatileFunc);
+    CPPUNIT_TEST(testFuncParam);
     CPPUNIT_TEST(testNamedRange);
     CPPUNIT_TEST(testCSV);
     CPPUNIT_TEST(testMatrix);
@@ -409,6 +411,29 @@ void Test::testVolatileFunc()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncParam()
+{
+    rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("foo"));
+    CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+                            m_pDoc->InsertTab (0, aTabName));
+
+    // First, the normal case, with no missing parameters.
+    m_pDoc->SetString(0, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("=AVERAGE(1;2;3)")));
+    m_pDoc->CalcFormulaTree(false, true);
+    double val;
+    m_pDoc->GetValue(0, 0, 0, val);
+    CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 2);
+
+    // Now function with missing parameters.  Missing values should be treated
+    // as zeros.
+    m_pDoc->SetString(0, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("=AVERAGE(1;;;)")));
+    m_pDoc->CalcFormulaTree(false, true);
+    m_pDoc->GetValue(0, 0, 0, val);
+    CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 0.25);
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testNamedRange()
 {
     rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Sheet1"));


More information about the Libreoffice-commits mailing list