diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-11 13:28:47 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-11 15:12:21 -0500 |
commit | 2ec3127da35933fc6d5ac47ecedd0267f67c1d62 (patch) | |
tree | 49f3b061b3f3964bb9b3e797c9ff011e1e2c6cfd /sc/qa | |
parent | b51acfb4c0c7dec0cdc3de5890ebb1c051bab509 (diff) |
Ensure that vector array has a numeric array of NaN's for empty range.
With this change, we ensure that mpNumArray is never NULL even when the
range consists entirely of empty cells. For an empty range, mpNumArray
will be non-NULL and filled with NaN's while mpStrArray will be NULL.
Change-Id: If5cead26ebe917af150cf7e39e17afe3f310beb7
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index a4b628953859..75553aebc3cd 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -490,6 +490,42 @@ void Test::testFetchVectorRefArray() CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, 5.0)); + // Clear everything and start over. + clearRange(m_pDoc, ScRange(0,0,0,MAXCOL,MAXROW,0)); + m_pDoc->ClearFormulaContext(); + + // Totally empty range in a totally empty column (Column A). + aArray = m_pDoc->FetchVectorRefArray(ScAddress(0,0,0), 3); // A1:A3 + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[0])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[1])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[2])); + + // Totally empty range in a non-empty column (Column B). + m_pDoc->SetString(ScAddress(1,10,0), "Some text"); // B11 + aArray = m_pDoc->FetchVectorRefArray(ScAddress(1,0,0), 3); // B1:B3 + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[0])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[1])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[2])); + + aArray = m_pDoc->FetchVectorRefArray(ScAddress(1,12,0), 3); // B13:B15 + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[0])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[1])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[2])); + + // These values come from a cache because of the call above. + aArray = m_pDoc->FetchVectorRefArray(ScAddress(1,1,0), 3); // B2:B4 + CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray); + CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[0])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[1])); + CPPUNIT_ASSERT(rtl::math::isNan(aArray.mpNumericArray[2])); + m_pDoc->DeleteTab(0); } |