From 71a8f79f4bdf567b6fce23091ca1663455cadba9 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 25 Jan 2013 13:15:09 +0100 Subject: improve the tests for cached value import The test now also tests for Err:* import and checks that these have been imported as error values and not only as text values. Future clean-up: Merge the cached matrix test file into the cached value one. Change-Id: I9c0a06f058ff6620bd7ca169b3bee07a5430997e --- sc/qa/unit/data/contentCSV/matrix2.csv | 12 ++++---- sc/qa/unit/data/ods/cachedValue.ods | Bin 9176 -> 9433 bytes sc/qa/unit/data/ods/matrix.ods | Bin 12992 -> 12934 bytes sc/qa/unit/data/ods/volatile.ods | Bin 7982 -> 0 bytes sc/qa/unit/subsequent_filters-test.cxx | 51 +++++++++++++++++++-------------- 5 files changed, 36 insertions(+), 27 deletions(-) delete mode 100644 sc/qa/unit/data/ods/volatile.ods (limited to 'sc/qa') diff --git a/sc/qa/unit/data/contentCSV/matrix2.csv b/sc/qa/unit/data/contentCSV/matrix2.csv index 2effd613c639..8450f0d01c62 100644 --- a/sc/qa/unit/data/contentCSV/matrix2.csv +++ b/sc/qa/unit/data/contentCSV/matrix2.csv @@ -1,6 +1,6 @@ -Matrices with errors and other misc potential problems:,,,, -Err:502,Err:502,Err:502,,error result -#N/A,#N/A,#N/A,,n/a -TRUE,TRUE,TRUE,,Display TRUE instead of 1 -FALSE,FALSE,FALSE,,Display FALSE instead of 0 -42,,42,,Display blank cell instead of 0 +Matrices with errors and other misc potential problems: +Err:502,Err:502,Err:502, +#N/A,#N/A,#N/A, +TRUE,TRUE,TRUE, +FALSE,FALSE,FALSE, +42,,42,, diff --git a/sc/qa/unit/data/ods/cachedValue.ods b/sc/qa/unit/data/ods/cachedValue.ods index a802e2205862..8fe411ab7666 100644 Binary files a/sc/qa/unit/data/ods/cachedValue.ods and b/sc/qa/unit/data/ods/cachedValue.ods differ diff --git a/sc/qa/unit/data/ods/matrix.ods b/sc/qa/unit/data/ods/matrix.ods index d3713cf82b2d..4d2f836567e3 100644 Binary files a/sc/qa/unit/data/ods/matrix.ods and b/sc/qa/unit/data/ods/matrix.ods differ diff --git a/sc/qa/unit/data/ods/volatile.ods b/sc/qa/unit/data/ods/volatile.ods deleted file mode 100644 index 6278de7c9c1e..000000000000 Binary files a/sc/qa/unit/data/ods/volatile.ods and /dev/null differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index a8c37cbc6189..6182bf32a42a 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -133,7 +133,6 @@ public: void testHardRecalcODS(); void testFunctionsODS(); void testCachedFormulaResultsODS(); - void testVolatileFunctionsODS(); void testCachedMatrixFormulaResultsODS(); void testDatabaseRangesODS(); void testDatabaseRangesXLS(); @@ -188,7 +187,6 @@ public: CPPUNIT_TEST(testHardRecalcODS); CPPUNIT_TEST(testFunctionsODS); CPPUNIT_TEST(testCachedFormulaResultsODS); - CPPUNIT_TEST(testVolatileFunctionsODS); CPPUNIT_TEST(testCachedMatrixFormulaResultsODS); CPPUNIT_TEST(testDatabaseRangesODS); CPPUNIT_TEST(testDatabaseRangesXLS); @@ -460,29 +458,40 @@ void ScFiltersTest::testCachedFormulaResultsODS() createCSVPath("cachedValue.", aCSVFileName); testFile(aCSVFileName, pDoc, 0); - xDocSh->DoClose(); - } -} + //we want to me sure that volatile functions are always recalculated + //regardless of cached results. if you update the ods file, you must + //update the values here. + //if NOW() is recacluated, then it should never equal sTodayCache + OUString sTodayCache("01/25/13 01:06 PM"); + OUString sTodayRecalc(pDoc->GetString(0,0,1)); -void ScFiltersTest::testVolatileFunctionsODS() -{ - ScDocShellRef xDocSh = loadDoc("volatile.", ODS); + CPPUNIT_ASSERT(sTodayCache != sTodayRecalc); - CPPUNIT_ASSERT_MESSAGE("Failed to load volatile.ods", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); - - //we want to me sure that volatile functions are always recalculated - //regardless of cached results. if you update the ods file, you must - //update the values here. - //if NOW() is recacluated, then it should never equal sTodayCache - OUString sTodayCache("07/11/12 12:28 AM"); - OUString sTodayRecalc(pDoc->GetString(0,1,0)); - CPPUNIT_ASSERT(sTodayCache != sTodayRecalc); + OUString sTodayRecalcRef(pDoc->GetString(1,0,1)); + CPPUNIT_ASSERT_EQUAL(sTodayRecalc, sTodayRecalcRef); - OUString sTodayRecalcRef(pDoc->GetString(2,1,0)); - CPPUNIT_ASSERT(sTodayCache != sTodayRecalcRef); + // make sure that error values are not being treated as string values + for(SCCOL nCol = 0; nCol < 4; ++nCol) + { + for(SCROW nRow = 0; nRow < 2; ++nRow) + { + OUStringBuffer aIsErrorFormula("=ISERROR("); + aIsErrorFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsErrorFormula.append(")"); + OUString aFormula = aIsErrorFormula.makeStringAndClear(); + pDoc->SetString(nCol, nRow + 2, 2, aFormula); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), pDoc->GetString(nCol, nRow +2, 2), OUString("TRUE")); + + OUStringBuffer aIsTextFormula("=ISTEXT("); + aIsTextFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsTextFormula.append(")"); + pDoc->SetString(nCol, nRow + 4, 2, aIsTextFormula.makeStringAndClear()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("", pDoc->GetString(nCol, nRow +4, 2), OUString("FALSE")); + } + } - xDocSh->DoClose(); + xDocSh->DoClose(); + } } void ScFiltersTest::testCachedMatrixFormulaResultsODS() -- cgit v1.2.3