Kaydet (Commit) a364a87f authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Add test for multiple operations. Part of it fails currently.

Change-Id: I90e3bbaae41fac51711b8502fbeb6ee2ebf19082
üst 13b69492
...@@ -93,6 +93,7 @@ public: ...@@ -93,6 +93,7 @@ public:
void testFormulaRefUpdateSheets(); void testFormulaRefUpdateSheets();
void testFormulaRefUpdateMove(); void testFormulaRefUpdateMove();
void testFormulaRefUpdateNamedExpression(); void testFormulaRefUpdateNamedExpression();
void testMultipleOperations();
void testFuncCOLUMN(); void testFuncCOLUMN();
void testFuncROW(); void testFuncROW();
void testFuncSUM(); void testFuncSUM();
...@@ -300,6 +301,7 @@ public: ...@@ -300,6 +301,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateSheets); CPPUNIT_TEST(testFormulaRefUpdateSheets);
CPPUNIT_TEST(testFormulaRefUpdateMove); CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression); CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
CPPUNIT_TEST(testMultipleOperations);
CPPUNIT_TEST(testFuncCOLUMN); CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncROW); CPPUNIT_TEST(testFuncROW);
CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncSUM);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "scmod.hxx" #include "scmod.hxx"
#include "docsh.hxx" #include "docsh.hxx"
#include "docfunc.hxx" #include "docfunc.hxx"
#include "paramisc.hxx"
#include "formula/vectortoken.hxx" #include "formula/vectortoken.hxx"
...@@ -1308,6 +1309,7 @@ void Test::testFormulaRefUpdateNamedExpression() ...@@ -1308,6 +1309,7 @@ void Test::testFormulaRefUpdateNamedExpression()
m_pDoc->SetValue(ScAddress(3,9,1), 10); m_pDoc->SetValue(ScAddress(3,9,1), 10);
CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(ScAddress(2,7,1))); 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); m_pDoc->DeleteTab(0);
aName = OUString(); aName = OUString();
...@@ -1341,6 +1343,58 @@ void Test::testFormulaRefUpdateNamedExpression() ...@@ -1341,6 +1343,58 @@ void Test::testFormulaRefUpdateNamedExpression()
m_pDoc->DeleteTab(0); 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() void Test::testFuncCOLUMN()
{ {
m_pDoc->InsertTab(0, "Formula"); m_pDoc->InsertTab(0, "Formula");
......
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