summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-28 11:16:29 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-28 11:59:23 -0400
commit18fa4733f46c2dae40bad7cdea9d3f98e24495dd (patch)
treedf425bddb5f4386f6754cae0a9e1c83594898373 /sc
parentd2f9e1a165314ad9e8588b1d44b3ff0a455ef7f6 (diff)
fdo#75397: Write unit test for this.
Change-Id: Id261aebd427eb032463668c2654ce837139b4a05
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx33
2 files changed, 35 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2939ac5bdec8..71b33a704c1f 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -133,6 +133,7 @@ public:
void testFuncN();
void testFuncCOUNTIF();
void testFuncNUMBERVALUE();
+ void testFuncLEN();
void testFuncLOOKUP();
void testFuncVLOOKUP();
void testFuncMATCH();
@@ -383,6 +384,7 @@ public:
CPPUNIT_TEST(testFuncN);
CPPUNIT_TEST(testFuncCOUNTIF);
CPPUNIT_TEST(testFuncNUMBERVALUE);
+ CPPUNIT_TEST(testFuncLEN);
CPPUNIT_TEST(testFuncLOOKUP);
CPPUNIT_TEST(testFuncVLOOKUP);
CPPUNIT_TEST(testFuncMATCH);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9776715d3ba6..b2caf2244c22 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2635,6 +2635,39 @@ void Test::testFuncNUMBERVALUE()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncLEN()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "Formula");
+
+ // Leave A1:A3 empty, and insert an array of LEN in B1:B3 that references
+ // these empty cells.
+
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ m_pDoc->InsertMatrixFormula(1, 0, 1, 2, aMark, "=LEN(A1:A3)", NULL);
+
+ ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT_MESSAGE("This formulashould be a matrix origin.",
+ pFC->GetMatrixFlag() == MM_FORMULA);
+
+ // This should be a 1x3 matrix.
+ SCCOL nCols = -1;
+ SCROW nRows = -1;
+ pFC->GetMatColsRows(nCols, nRows);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCols);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), nRows);
+
+ // LEN value should be 0 for an empty cell.
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncLOOKUP()
{
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);