[Libreoffice-commits] core.git: Branch 'private/kohei/if-or-not-if-jump' - sc/qa

Kohei Yoshida kohei.yoshida at collabora.com
Wed May 14 19:53:05 PDT 2014


 sc/qa/unit/ucalc.hxx         |    2 ++
 sc/qa/unit/ucalc_formula.cxx |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 2b4666435cde4a029d5c059266212a540220fee2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed May 14 22:52:50 2014 -0400

    Add test for CHOOSE function.
    
    This function is also a jump function requiring a special RPN reordering.
    
    Change-Id: I34f68875febeb4fb8c78527d763d4a6352f50b03

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 6726d9b..35d57ce 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -154,6 +154,7 @@ public:
     void testFuncDATEDIF();
     void testFuncINDIRECT();
     void testFuncIF();
+    void testFuncCHOOSE();
     void testFuncIFERROR();
     void testFuncSHEET();
     void testFuncNOW();
@@ -416,6 +417,7 @@ public:
     CPPUNIT_TEST(testFuncDATEDIF);
     CPPUNIT_TEST(testFuncINDIRECT);
     CPPUNIT_TEST(testFuncIF);
+    CPPUNIT_TEST(testFuncCHOOSE);
     CPPUNIT_TEST(testFuncIFERROR);
     CPPUNIT_TEST(testFuncGETPIVOTDATA);
     CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index efd1d8c..7720881 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2809,6 +2809,28 @@ void Test::testFuncIF()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncCHOOSE()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+    m_pDoc->InsertTab(0, "Formula");
+
+    m_pDoc->SetString(ScAddress(0,0,0), "=CHOOSE(B1;\"one\";\"two\";\"three\")");
+    sal_uInt16 nError = m_pDoc->GetErrCode(ScAddress(0,0,0));
+    CPPUNIT_ASSERT_MESSAGE("Formula result should be an error since B1 is still empty.", nError);
+    m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
+    CPPUNIT_ASSERT_EQUAL(OUString("one"), m_pDoc->GetString(ScAddress(0,0,0)));
+    m_pDoc->SetValue(ScAddress(1,0,0), 2.0);
+    CPPUNIT_ASSERT_EQUAL(OUString("two"), m_pDoc->GetString(ScAddress(0,0,0)));
+    m_pDoc->SetValue(ScAddress(1,0,0), 3.0);
+    CPPUNIT_ASSERT_EQUAL(OUString("three"), m_pDoc->GetString(ScAddress(0,0,0)));
+    m_pDoc->SetValue(ScAddress(1,0,0), 4.0);
+    nError = m_pDoc->GetErrCode(ScAddress(0,0,0));
+    CPPUNIT_ASSERT_MESSAGE("Formula result should be an error due to out-of-bound input..", nError);
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFuncIFERROR()
 {
     // IFERROR/IFNA (fdo#56124)


More information about the Libreoffice-commits mailing list