diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-04-14 22:46:33 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-04-14 22:46:33 -0400 |
commit | f671eccb839f4407f7c1e6336e64243b46a6e42e (patch) | |
tree | bc12d14fbf05ce805a8d557bb34b37e2008fc2bf /sc/qa/unit | |
parent | 6bd7d86f354d80e0ff6aaa5f3dcc5c4077314d34 (diff) |
New test for function evaluation with missing parameters.
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index a5127138d1ae..2e65aeecc465 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")); |