summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-14 22:52:50 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-14 22:52:50 -0400
commit2b4666435cde4a029d5c059266212a540220fee2 (patch)
treef8b27f72b4335e04516a6715b6ceaeb0e7539bea
parent223dbffa46ed3a1bfc0b47a7cfc7792ec9893b3b (diff)
Add test for CHOOSE function.private/kohei/if-or-not-if-jump
This function is also a jump function requiring a special RPN reordering. Change-Id: I34f68875febeb4fb8c78527d763d4a6352f50b03
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx22
2 files changed, 24 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 6726d9b274b5..35d57ceec8a9 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 efd1d8cb7b4f..772088135574 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)