Kaydet (Commit) b684090d authored tarafından Eike Rathke's avatar Eike Rathke

unit tests for formula error propagation, tdf#94869 related

Change-Id: Ia80de96f40d0abe391a530f74ef2b17a1dc2baae
üst 07bc49b4
...@@ -452,6 +452,7 @@ public: ...@@ -452,6 +452,7 @@ public:
// tdf#80137 // tdf#80137
void testCopyPasteMatrixFormula(); void testCopyPasteMatrixFormula();
void testUndoDataAnchor(); void testUndoDataAnchor();
void testFormulaErrorPropagation();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if CALC_TEST_PERF #if CALC_TEST_PERF
...@@ -679,6 +680,7 @@ public: ...@@ -679,6 +680,7 @@ public:
CPPUNIT_TEST(testSetStringAndNote); CPPUNIT_TEST(testSetStringAndNote);
CPPUNIT_TEST(testCopyPasteMatrixFormula); CPPUNIT_TEST(testCopyPasteMatrixFormula);
CPPUNIT_TEST(testUndoDataAnchor); CPPUNIT_TEST(testUndoDataAnchor);
CPPUNIT_TEST(testFormulaErrorPropagation);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
......
...@@ -6431,4 +6431,79 @@ void Test::testFuncSUMSQ() ...@@ -6431,4 +6431,79 @@ void Test::testFuncSUMSQ()
m_pDoc->DeleteTab(0); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment