diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-14 22:12:19 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-14 22:12:19 -0400 |
commit | 223dbffa46ed3a1bfc0b47a7cfc7792ec9893b3b (patch) | |
tree | b659b1472d224cf77b9fe3ae8bd5b71213957ac8 | |
parent | fd50548489e1804b20c2a7896a4c82a6c617adf7 (diff) |
Add unit test for IF function.
Change-Id: I2265458883fb05582c54157714b88345362efa0d
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 6291fd94e485..6726d9b274b5 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -153,6 +153,7 @@ public: void testFuncCELL(); void testFuncDATEDIF(); void testFuncINDIRECT(); + void testFuncIF(); void testFuncIFERROR(); void testFuncSHEET(); void testFuncNOW(); @@ -414,6 +415,7 @@ public: CPPUNIT_TEST(testFuncCELL); CPPUNIT_TEST(testFuncDATEDIF); CPPUNIT_TEST(testFuncINDIRECT); + CPPUNIT_TEST(testFuncIF); 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 3b374d754827..efd1d8cb7b4f 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2793,6 +2793,22 @@ void Test::testFuncCOUNTIF() m_pDoc->DeleteTab(0); } +void Test::testFuncIF() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + + m_pDoc->InsertTab(0, "Formula"); + + m_pDoc->SetString(ScAddress(0,0,0), "=IF(B1=2;\"two\";\"not two\")"); + CPPUNIT_ASSERT_EQUAL(OUString("not two"), 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("not two"), m_pDoc->GetString(ScAddress(0,0,0))); + + m_pDoc->DeleteTab(0); +} + void Test::testFuncIFERROR() { // IFERROR/IFNA (fdo#56124) |