summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-24 19:15:38 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-24 19:44:52 -0400
commit380631d0e24d8bf90a5431b3e3c5fb36f21dbcf0 (patch)
treecb9417e45f2f0c2df250df8b4aae6b7dc667646b
parente0be1a74444683f760d90f88cc3be14d9b377591 (diff)
fdo#77039: Write test for this.
Change-Id: If34291ffb9705c413a451091ac70d7f2c7ea8f63
-rw-r--r--sc/qa/unit/ucalc_formula.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 254962e506c5..e3283dbcb5d9 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2294,6 +2294,8 @@ void Test::testFuncN()
void Test::testFuncCOUNTIF()
{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
// COUNTIF (test case adopted from OOo i#36381)
OUString aTabName("foo");
@@ -2345,7 +2347,6 @@ void Test::testFuncCOUNTIF()
SCROW nRow = 20 + i;
m_pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
- m_pDoc->CalcAll();
for (SCROW i = 0; i < nRows; ++i)
{
@@ -2368,11 +2369,23 @@ void Test::testFuncCOUNTIF()
m_pDoc->SetString(0, 0, 0, OUString("=\"\""));
m_pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)"));
- m_pDoc->CalcAll();
double result = m_pDoc->GetValue(0, 1, 0);
CPPUNIT_ASSERT_MESSAGE("We shouldn't count empty string as valid number.", result == 0.0);
+ // Another test case adopted from fdo#77039.
+ clearSheet(m_pDoc, 0);
+
+ // Set formula cells with blank results in A1:A4.
+ for (SCROW i = 0; i <=3; ++i)
+ m_pDoc->SetString(ScAddress(0,i,0), "=\"\"");
+
+ // Insert formula into A5 to count all cells with empty strings.
+ m_pDoc->SetString(ScAddress(0,4,0), "=COUNTIF(A1:A4;\"\"");
+
+ // We should correctly count with empty string key.
+ CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+
m_pDoc->DeleteTab(0);
}