diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-03-03 01:09:24 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-03-03 01:09:24 -0500 |
commit | f8c96ac67e1919eab8058fffb68e52e6a8c392c5 (patch) | |
tree | 1094a1bd67885f87c0c88494003e9e6e67f0460e /sc/qa | |
parent | ababcf5570c93461e7fff7a9adc631891f04b56d (diff) |
Added new test for volatile function NOW wrapped inside IF.
Inspired by fdo#31939.
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index b5b52709d206..5b9a2d26ad56 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -228,6 +228,7 @@ public: void testCollator(); void testSUM(); + void testVolatileFunc(); void testNamedRange(); void testCSV(); void testMatrix(); @@ -250,6 +251,7 @@ public: CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testCollator); CPPUNIT_TEST(testSUM); + CPPUNIT_TEST(testVolatileFunc); CPPUNIT_TEST(testNamedRange); CPPUNIT_TEST(testCSV); CPPUNIT_TEST(testMatrix); @@ -347,6 +349,36 @@ void Test::testSUM() m_pDoc->DeleteTab(0); } +void Test::testVolatileFunc() +{ + rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("foo")); + CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", + m_pDoc->InsertTab (0, aTabName)); + + double val = 1; + m_pDoc->SetValue(0, 0, 0, val); + m_pDoc->SetString(0, 1, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("=IF(A1>0;NOW();0"))); + double now1; + m_pDoc->GetValue(0, 1, 0, now1); + CPPUNIT_ASSERT_MESSAGE("Value of NOW() should be positive.", now1 > 0.0); + + val = 0; + m_pDoc->SetValue(0, 0, 0, val); + m_xDocShRef->DoRecalc(true); + double zero; + m_pDoc->GetValue(0, 1, 0, zero); + CPPUNIT_ASSERT_MESSAGE("Result should equal the 3rd parameter of IF, which is zero.", zero == 0.0); + + val = 1; + m_pDoc->SetValue(0, 0, 0, val); + m_xDocShRef->DoRecalc(true); + double now2; + m_pDoc->GetValue(0, 1, 0, now2); + CPPUNIT_ASSERT_MESSAGE("Result should be the value of NOW() again.", (now2 - now1) >= 0.0); + + m_pDoc->DeleteTab(0); +} + void Test::testNamedRange() { rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Sheet1")); |