[Libreoffice-commits] core.git: sc/qa
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Mar 7 15:57:45 PST 2014
sc/qa/unit/ucalc.cxx | 63 -------------------------------------------
sc/qa/unit/ucalc.hxx | 12 ++------
sc/qa/unit/ucalc_formula.cxx | 63 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 71 deletions(-)
New commits:
commit 335a8a84fe6349fd716d4978346cfff9c884dd9b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Mar 7 18:55:11 2014 -0500
Move these tests to ucalc_formula.
Since they are for cell functions.
Change-Id: I1e340d35cf3a976ff3b9aeb5860cc4361e2ee89d
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a49b6d2..fd5fa64 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -963,69 +963,6 @@ void Test::testCopyToDocument()
m_pDoc->DeleteTab(0);
}
-void Test::testSheetsFunc()
-{
- OUString aTabName1("test1");
- OUString aTabName2("test2");
- CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- m_pDoc->InsertTab (SC_TAB_APPEND, aTabName1));
-
- m_pDoc->SetString(0, 0, 0, OUString("=SHEETS()"));
- m_pDoc->CalcFormulaTree(false, false);
- double original;
- m_pDoc->GetValue(0, 0, 0, original);
-
- CPPUNIT_ASSERT_MESSAGE("result of SHEETS() should equal the number of sheets, but doesn't.",
- static_cast<SCTAB>(original) == m_pDoc->GetTableCount());
-
- CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- m_pDoc->InsertTab (SC_TAB_APPEND, aTabName2));
-
- double modified;
- m_pDoc->GetValue(0, 0, 0, modified);
- CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet insertion.",
- modified - original == 1.0);
-
- SCTAB nTabCount = m_pDoc->GetTableCount();
- m_pDoc->DeleteTab(--nTabCount);
-
- m_pDoc->GetValue(0, 0, 0, modified);
- CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet removal.",
- modified - original == 0.0);
-
- m_pDoc->DeleteTab(--nTabCount);
-}
-
-void Test::testVolatileFunc()
-{
- OUString aTabName("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("=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_pDoc->CalcFormulaTree(false, false);
- 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_pDoc->CalcFormulaTree(false, false);
- 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);
-}
-
namespace {
struct HoriIterCheck
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f51556f..7c40fb8 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -136,6 +136,8 @@ public:
void testFuncDATEDIF();
void testFuncINDIRECT();
void testFuncIFERROR();
+ void testFuncSHEET();
+ void testFuncNOW();
void testFuncGETPIVOTDATA();
void testFuncGETPIVOTDATALeafAccess();
@@ -143,12 +145,6 @@ public:
void testExternalRefFunctions();
void testCopyToDocument();
- /**
- * Make sure the SHEETS function gets properly updated during sheet
- * insertion and removal.
- */
- void testSheetsFunc();
- void testVolatileFunc();
void testHorizontalIterator();
void testValueIterator();
@@ -385,8 +381,8 @@ public:
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testExternalRefFunctions);
CPPUNIT_TEST(testCopyToDocument);
- CPPUNIT_TEST(testSheetsFunc);
- CPPUNIT_TEST(testVolatileFunc);
+ CPPUNIT_TEST(testFuncSHEET);
+ CPPUNIT_TEST(testFuncNOW);
CPPUNIT_TEST(testHorizontalIterator);
CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f4c6f7a..69fe420 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2192,6 +2192,69 @@ void Test::testFuncIFERROR()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncSHEET()
+{
+ OUString aTabName1("test1");
+ OUString aTabName2("test2");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (SC_TAB_APPEND, aTabName1));
+
+ m_pDoc->SetString(0, 0, 0, OUString("=SHEETS()"));
+ m_pDoc->CalcFormulaTree(false, false);
+ double original;
+ m_pDoc->GetValue(0, 0, 0, original);
+
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() should equal the number of sheets, but doesn't.",
+ static_cast<SCTAB>(original) == m_pDoc->GetTableCount());
+
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (SC_TAB_APPEND, aTabName2));
+
+ double modified;
+ m_pDoc->GetValue(0, 0, 0, modified);
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet insertion.",
+ modified - original == 1.0);
+
+ SCTAB nTabCount = m_pDoc->GetTableCount();
+ m_pDoc->DeleteTab(--nTabCount);
+
+ m_pDoc->GetValue(0, 0, 0, modified);
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet removal.",
+ modified - original == 0.0);
+
+ m_pDoc->DeleteTab(--nTabCount);
+}
+
+void Test::testFuncNOW()
+{
+ OUString aTabName("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("=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_pDoc->CalcFormulaTree(false, false);
+ 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_pDoc->CalcFormulaTree(false, false);
+ 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::testFuncNUMBERVALUE()
{
// NUMBERVALUE fdo#57180
More information about the Libreoffice-commits
mailing list