sc/qa/unit/ucalc.hxx | 2 + sc/qa/unit/ucalc_formula.cxx | 54 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
New commits: commit fe04dbc12b9c02a8b7ac6040290712086c023382 Author: Kohei Yoshida <[email protected]> Date: Fri Nov 1 15:16:40 2013 -0400 Add test for multiple operations. Part of it fails currently. Change-Id: I90e3bbaae41fac51711b8502fbeb6ee2ebf19082 diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 5689435..b9c1d42 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -93,6 +93,7 @@ public: void testFormulaRefUpdateSheets(); void testFormulaRefUpdateMove(); void testFormulaRefUpdateNamedExpression(); + void testMultipleOperations(); void testFuncCOLUMN(); void testFuncROW(); void testFuncSUM(); @@ -300,6 +301,7 @@ public: CPPUNIT_TEST(testFormulaRefUpdateSheets); CPPUNIT_TEST(testFormulaRefUpdateMove); CPPUNIT_TEST(testFormulaRefUpdateNamedExpression); + CPPUNIT_TEST(testMultipleOperations); CPPUNIT_TEST(testFuncCOLUMN); CPPUNIT_TEST(testFuncROW); CPPUNIT_TEST(testFuncSUM); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 361c015..0e54fb0 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -21,6 +21,7 @@ #include "scmod.hxx" #include "docsh.hxx" #include "docfunc.hxx" +#include "paramisc.hxx" #include "formula/vectortoken.hxx" @@ -1274,6 +1275,7 @@ void Test::testFormulaRefUpdateNamedExpression() m_pDoc->SetValue(ScAddress(3,9,1), 10); CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(ScAddress(2,7,1))); + // Delete the inserted sheet, which will shift the 'Formula' sheet to the left. m_pDoc->DeleteTab(0); aName = OUString(); @@ -1307,6 +1309,58 @@ void Test::testFormulaRefUpdateNamedExpression() m_pDoc->DeleteTab(0); } +void Test::testMultipleOperations() +{ + m_pDoc->InsertTab(0, "MultiOp"); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + + // Insert the reference formula at top row. + m_pDoc->SetValue(ScAddress(0,0,0), 1); + m_pDoc->SetString(ScAddress(1,0,0), "=A1*10"); + CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0))); + + // Insert variable inputs in A3:A5. + m_pDoc->SetValue(ScAddress(0,2,0), 2); + m_pDoc->SetValue(ScAddress(0,3,0), 3); + m_pDoc->SetValue(ScAddress(0,4,0), 4); + + // Set multiple operations range. + ScTabOpParam aParam; + aParam.aRefFormulaCell = ScRefAddress(1,0,0,false,false,false); + aParam.aRefFormulaEnd = aParam.aRefFormulaCell; + aParam.aRefColCell = ScRefAddress(0,0,0,false,false,false); + ScMarkData aMark; + aMark.SetMarkArea(ScRange(0,2,0,1,4,0)); // Select A3:B5. + m_pDoc->InsertTableOp(aParam, 0, 2, 1, 4, aMark); + CPPUNIT_ASSERT_EQUAL(20.0, m_pDoc->GetValue(1,2,0)); + CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(1,3,0)); + CPPUNIT_ASSERT_EQUAL(40.0, m_pDoc->GetValue(1,4,0)); + + // Clear A3:B5. + clearRange(m_pDoc, ScRange(0,2,0,1,4,0)); + + // This time, use indirect reference formula cell. + m_pDoc->SetString(ScAddress(2,0,0), "=B1"); // C1 simply references B1. + CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(2,0,0))); + + // Insert variable inputs in A3:A5. + m_pDoc->SetValue(ScAddress(0,2,0), 3); + m_pDoc->SetValue(ScAddress(0,3,0), 4); + m_pDoc->SetValue(ScAddress(0,4,0), 5); + + // Set multiple operations range again, but this time, we'll use C1 as the reference formula. + aParam.aRefFormulaCell.Set(2,0,0,false,false,false); + aParam.aRefFormulaEnd = aParam.aRefFormulaCell; + m_pDoc->InsertTableOp(aParam, 0, 2, 1, 4, aMark); +#if 0 // TODO: Make this pass. + CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(1,2,0)); + CPPUNIT_ASSERT_EQUAL(40.0, m_pDoc->GetValue(1,3,0)); + CPPUNIT_ASSERT_EQUAL(50.0, m_pDoc->GetValue(1,4,0)); +#endif + m_pDoc->DeleteTab(0); +} + void Test::testFuncCOLUMN() { m_pDoc->InsertTab(0, "Formula"); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
