summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaskaran <jvsg1303@gmail.com>2016-03-13 10:27:48 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-19 16:14:14 +0100
commit2fd81edb9a6b89e1aa2d9c83006ad28660f85d71 (patch)
treef99a099a636e19b767d2bc58b2cf22093ddc69e8
parent187669de1096ebbf4347ec1126eb6b693f6c5a96 (diff)
tdf#70448, Test for SetFormula function
Change-Id: Ie6899b90f02f8344710515af847170783a5e0d0f
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_column.cxx32
2 files changed, 34 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 996652c53ec5..b4efe3d4addb 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -460,6 +460,7 @@ public:
void testCopyPasteMatrixFormula();
void testUndoDataAnchor();
void testFormulaErrorPropagation();
+ void testSetFormula();
void testTdf97369();
void testTdf97587();
@@ -696,6 +697,7 @@ public:
CPPUNIT_TEST(testCopyPasteMatrixFormula);
CPPUNIT_TEST(testUndoDataAnchor);
CPPUNIT_TEST(testFormulaErrorPropagation);
+ CPPUNIT_TEST(testSetFormula);
CPPUNIT_TEST(testTdf97369);
CPPUNIT_TEST(testTdf97587);
CPPUNIT_TEST_SUITE_END();
diff --git a/sc/qa/unit/ucalc_column.cxx b/sc/qa/unit/ucalc_column.cxx
index 2aaba3b7dbd4..51e0553b5203 100644
--- a/sc/qa/unit/ucalc_column.cxx
+++ b/sc/qa/unit/ucalc_column.cxx
@@ -93,4 +93,36 @@ void Test::testColumnFindEditCells()
m_pDoc->DeleteTab(0);
}
+
+void Test::testSetFormula()
+{
+
+ struct aInputs
+ {
+ const char* aName;
+ SCTAB nTab;
+ SCROW nRow;
+ SCCOL nCol;
+ const char* aFormula1; // Represents the formula that is input to SetFormula function.
+ const char* aFormula2; // Represents the formula that is actually stored in the cell.
+ formula::FormulaGrammar::Grammar eGram;
+
+ } aTest[] = {
+ { "Rock and Roll" ,0 ,5 , 4 , "=SUM($D$2:$F$3)" ,"=SUM($D$2:$F$3)" , formula::FormulaGrammar::Grammar::GRAM_ENGLISH },
+ { "Blues" ,1 ,5 , 5 , "=A1-$C2+B$3-$F$4" ,"=A1-$C2+B$3-$F$4", formula::FormulaGrammar::Grammar::GRAM_NATIVE },
+ { "Acoustic" ,2 ,6 , 6 , "=A1-$C2+B$3-$F$4" ,"=A1-$C2+B$3-$F$4", formula::FormulaGrammar::Grammar::GRAM_NATIVE_XL_A1},
+ { "Nursery Rhymes",3 ,7 , 8 , "=[.A1]-[.$C2]+[.G$3]-[.$F$4]","=A1-$C2+G$3-$F$4", formula::FormulaGrammar::Grammar::GRAM_ODFF }
+ };
+
+ for(size_t i = 0 ; i < SAL_N_ELEMENTS(aTest) ;++i)
+ {
+ m_pDoc->InsertTab(aTest[i].nTab,OUString::createFromAscii(aTest[i].aName));
+ OUString aBuffer("123");
+ m_pDoc->SetFormula(ScAddress(aTest[i].nCol,aTest[i].nRow,aTest[i].nTab) , OUString::createFromAscii(aTest[i].aFormula1) ,aTest[i].eGram);
+ m_pDoc->GetFormula(aTest[i].nCol,aTest[i].nRow,aTest[i].nTab, aBuffer);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to set formula",OUString::createFromAscii(aTest[i].aFormula2),aBuffer);
+
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */