[Libreoffice-commits] core.git: sc/qa
Eike Rathke
erack at redhat.com
Tue Jun 27 14:18:17 UTC 2017
sc/qa/unit/ucalc_formula.cxx | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
New commits:
commit 7567074894a7ad48a82ea35eead51bac9fafa19b
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jun 27 16:17:27 2017 +0200
Unit test for update reference in deletion of last col/row, tdf#108788
Change-Id: Ibb7a30144a1eebac3b233320c3d56c7be41cc7e3
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9d8264b1f0e4..d9c09eaa6a58 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1712,6 +1712,36 @@ void Test::testFormulaRefUpdateRange()
ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A17 after deletion.");
aPos.IncRow();
+ // Enter values in B1 and B1048576 (last row).
+ m_pDoc->SetValue( 1,0,1, 1.0);
+ m_pDoc->SetValue( 1,MAXROW,1, 2.0);
+ // Sticky reference including last row.
+ m_pDoc->SetString( 2,0,1, "=SUM(B:B)");
+ // Reference to last row.
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXROW changed, adapt unit test.", 1048575, (int)MAXROW);
+ m_pDoc->SetString( 2,1,1, "=SUM(B1048576:C1048576)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C1.", 3.0, m_pDoc->GetValue(2,0,1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C2.", 2.0, m_pDoc->GetValue(2,1,1));
+ // Delete last row.
+ m_pDoc->DeleteRow( ScRange( 0, MAXROW, 1, MAXCOL, MAXROW, 1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C1.", 1.0, m_pDoc->GetValue(2,0,1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Reference in C2 not invalidated.", OUString("#REF!"), m_pDoc->GetString(2,1,1));
+
+ // Enter values in A23 and AMJ23 (last column).
+ m_pDoc->SetValue( 0,22,1, 1.0);
+ m_pDoc->SetValue( MAXCOL,22,1, 2.0);
+ // C3 with sticky reference including last column.
+ m_pDoc->SetString( 2,2,1, "=SUM(23:23)");
+ // C4 with reference to last column.
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXCOL changed, adapt unit test.", 1023, (int)MAXCOL);
+ m_pDoc->SetString( 2,3,1, "=SUM(AMJ22:AMJ23)");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C3.", 3.0, m_pDoc->GetValue(2,2,1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C4.", 2.0, m_pDoc->GetValue(2,3,1));
+ // Delete last column.
+ m_pDoc->DeleteCol( ScRange( MAXCOL, 0, 1, MAXCOL, MAXROW, 1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C3.", 1.0, m_pDoc->GetValue(2,2,1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Reference in C4 not invalidated.", OUString("#REF!"), m_pDoc->GetString(2,3,1));
+
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
More information about the Libreoffice-commits
mailing list