summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-05-20 22:14:43 +0200
committerEike Rathke <erack@redhat.com>2016-05-20 22:15:29 +0200
commit34e70369f571c78e4bb235470ce710f531e0d026 (patch)
treea492cba443acda3753a53eed10a913b97fe5f61f
parent9512dd16c92231514b9a5df3891517861a882d73 (diff)
unit test for unresolved external references, tdf#93101
Change-Id: I02d948206aeba56a8d825646eeef0fcbf6e9b505
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx80
2 files changed, 82 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9ff01c0ad78d..1b309f6e5766 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -197,6 +197,7 @@ public:
void testExternalRef();
void testExternalRefFunctions();
void testExternalRangeName();
+ void testExternalRefUnresolved();
void testCopyToDocument();
@@ -564,6 +565,7 @@ public:
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testExternalRangeName);
CPPUNIT_TEST(testExternalRefFunctions);
+ CPPUNIT_TEST(testExternalRefUnresolved);
CPPUNIT_TEST(testCopyToDocument);
CPPUNIT_TEST(testFuncSHEET);
CPPUNIT_TEST(testFuncNOW);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index fb63065599e5..14b292933606 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -5619,6 +5619,86 @@ void Test::testExternalRefFunctions()
m_pDoc->DeleteTab(0);
}
+void Test::testExternalRefUnresolved()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+ m_pDoc->InsertTab(0, "Test");
+
+ // Test error propagation of unresolved (not existing document) external
+ // references. Well, let's hope no build machine has such file with sheet..
+
+ const char* aData[][1] = {
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1+23" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1&\"W\"" },
+ { "=ISREF('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISERROR('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISERR('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISBLANK('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISNUMBER('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISTEXT('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1)" },
+ { "=ISNUMBER('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1+23)" },
+ { "=ISTEXT('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1&\"W\")" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1=0" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1=\"\"" },
+ { "=INDIRECT(\"'file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1\")" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2+23" },
+ { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2&\"W\"" },
+ { "=ISREF('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISERROR('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISERR('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISBLANK('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISNUMBER('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISTEXT('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2)" },
+ { "=ISNUMBER('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2+23)" },
+ { "=ISTEXT('file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2&\"W\")" },
+ // TODO: gives Err:504 FIXME { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2=0" },
+ // TODO: gives Err:504 FIXME { "='file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2=\"\"" },
+ { "=INDIRECT(\"'file:///NonExistingFilePath/AnyName.ods'#$NoSuchSheet.A1:A2\")" },
+ };
+
+ ScAddress aPos(0,0,0);
+ ScRange aRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+ CPPUNIT_ASSERT_EQUAL(aPos, aRange.aStart);
+
+ const char* aOutputCheck[][1] = {
+ { "#REF!" }, // plain single ref
+ { "#REF!" }, // +23
+ { "#REF!" }, // &"W"
+ { "FALSE" }, // ISREF
+ { "TRUE" }, // ISERROR
+ { "TRUE" }, // ISERR
+ { "FALSE" }, // ISBLANK
+ { "FALSE" }, // ISNUMBER
+ { "FALSE" }, // ISTEXT
+ { "FALSE" }, // ISNUMBER
+ { "FALSE" }, // ISTEXT
+ { "#REF!" }, // =0
+ { "#REF!" }, // =""
+ { "#REF!" }, // INDIRECT
+ { "#REF!" }, // A1:A2 range
+ { "#REF!" }, // +23
+ { "#REF!" }, // &"W"
+ { "FALSE" }, // ISREF
+ { "TRUE" }, // ISERROR
+ { "TRUE" }, // ISERR
+ { "FALSE" }, // ISBLANK
+ { "FALSE" }, // ISNUMBER
+ { "FALSE" }, // ISTEXT
+ { "FALSE" }, // ISNUMBER
+ { "FALSE" }, // ISTEXT
+ // TODO: gives Err:504 FIXME { "#REF!" }, // =0
+ // TODO: gives Err:504 FIXME { "#REF!" }, // =""
+ { "#REF!" }, // INDIRECT
+ };
+
+ bool bSuccess = checkOutput<1>(m_pDoc, aRange, aOutputCheck, "Check unresolved external reference.");
+ CPPUNIT_ASSERT_MESSAGE("Unresolved reference check failed", bSuccess);
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testMatrixOp()
{
m_pDoc->InsertTab(0, "Test");