[Libreoffice-commits] core.git: sc/qa
Eike Rathke
erack at redhat.com
Thu Oct 15 17:39:04 PDT 2015
sc/qa/unit/ucalc.hxx | 2 +
sc/qa/unit/ucalc_formula.cxx | 75 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
New commits:
commit b684090d4f573eb339e93872d0cef07e69adc913
Author: Eike Rathke <erack at redhat.com>
Date: Fri Oct 16 00:54:03 2015 +0200
unit tests for formula error propagation, tdf#94869 related
Change-Id: Ia80de96f40d0abe391a530f74ef2b17a1dc2baae
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index eb8e047..442dfb8 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -452,6 +452,7 @@ public:
// tdf#80137
void testCopyPasteMatrixFormula();
void testUndoDataAnchor();
+ void testFormulaErrorPropagation();
CPPUNIT_TEST_SUITE(Test);
#if CALC_TEST_PERF
@@ -679,6 +680,7 @@ public:
CPPUNIT_TEST(testSetStringAndNote);
CPPUNIT_TEST(testCopyPasteMatrixFormula);
CPPUNIT_TEST(testUndoDataAnchor);
+ CPPUNIT_TEST(testFormulaErrorPropagation);
CPPUNIT_TEST_SUITE_END();
private:
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 0badcac..df8fe31 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -6431,4 +6431,79 @@ void Test::testFuncSUMSQ()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaErrorPropagation()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "Sheet1");
+
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ ScAddress aPos, aPos2;
+ const OUString aTRUE("TRUE");
+ const OUString aFALSE("FALSE");
+
+ aPos.Set(0,0,0);// A1
+ m_pDoc->SetValue( aPos, 1.0);
+ aPos.IncCol(); // B1
+ m_pDoc->SetValue( aPos, 2.0);
+ aPos.IncCol();
+
+ aPos.IncRow(); // C2
+ m_pDoc->SetString( aPos, "=ISERROR(A1:B1+3)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+
+ aPos.IncRow(); // C3
+ m_pDoc->SetString( aPos, "=ISERROR(A1:B1+{3})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+ aPos.IncRow(); // C4
+ aPos2 = aPos;
+ aPos2.IncCol(); // D4
+ m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(A1:B1+{3})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2));
+
+ aPos.IncRow(); // C5
+ m_pDoc->SetString( aPos, "=ISERROR({1;\"x\"}+{3;4})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos));
+ aPos.IncRow(); // C6
+ aPos2 = aPos;
+ aPos2.IncCol(); // D6
+ m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR({1;\"x\"}+{3;4})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2));
+
+ aPos.IncRow(); // C7
+ m_pDoc->SetString( aPos, "=ISERROR({\"x\";2}+{3;4})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+ aPos.IncRow(); // C8
+ aPos2 = aPos;
+ aPos2.IncCol(); // D8
+ m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR({\"x\";2}+{3;4})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2));
+
+ aPos.IncRow(); // C9
+ m_pDoc->SetString( aPos, "=ISERROR(({1;\"x\"}+{3;4})-{5;6})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos));
+ aPos.IncRow(); // C10
+ aPos2 = aPos;
+ aPos2.IncCol(); // D10
+ m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(({1;\"x\"}+{3;4})-{5;6})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2));
+
+ aPos.IncRow(); // C11
+ m_pDoc->SetString( aPos, "=ISERROR(({\"x\";2}+{3;4})-{5;6})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+ aPos.IncRow(); // C12
+ aPos2 = aPos;
+ aPos2.IncCol(); // D12
+ m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(({\"x\";2}+{3;4})-{5;6})");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2));
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list