diff options
author | Eike Rathke <erack@redhat.com> | 2015-10-16 00:54:03 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-10-16 02:36:38 +0200 |
commit | b684090d4f573eb339e93872d0cef07e69adc913 (patch) | |
tree | b3696e2907411f4d65ecc8c038321883f083ddff /sc/qa | |
parent | 07bc49b43187ecc691d98eec1b9b129cf92efd70 (diff) |
unit tests for formula error propagation, tdf#94869 related
Change-Id: Ia80de96f40d0abe391a530f74ef2b17a1dc2baae
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 75 |
2 files changed, 77 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index eb8e047af1e7..442dfb81f5b6 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 0badcac64f44..df8fe31af77a 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: */ |