diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-01 15:16:40 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-04 13:59:17 -0500 |
commit | a364a87f73fc2730a987992a8d4242bc12f788d0 (patch) | |
tree | a10661cb6824654e52b4518a4f893d8a6f73bab1 | |
parent | 13b69492716c506976a31a26fe0590aa06b3d1a3 (diff) |
Add test for multiple operations. Part of it fails currently.
Change-Id: I90e3bbaae41fac51711b8502fbeb6ee2ebf19082
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 54 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 56894352cd2b..b9c1d42a7c45 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 598c65df68e5..3cb9ab90b7f2 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" @@ -1308,6 +1309,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(); @@ -1341,6 +1343,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"); |