summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-22 23:13:57 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-24 23:29:37 -0400
commitf7b4c1ce8d024b7f1faf04073ef0544d5074e71d (patch)
tree5d23320225e043eb296673c85bf7079fae1d771b /sc
parenta5890efca5231b5141897a13f0a19406addb6d72 (diff)
Add test for extending range reference.
Change-Id: I882f312fd0908d83203da5b48d9c3f4d002e8dd0
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc_formula.cxx48
1 files changed, 34 insertions, 14 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index b2739d149bc0..0aee2eb01016 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -117,20 +117,40 @@ void Test::testFormulaHashAndTag()
void Test::testFormulaRefData()
{
ScAddress aAddr(4,5,3), aPos(2,2,2);
- ScSingleRefData aRefData;
- aRefData.InitAddress(aAddr);
- CPPUNIT_ASSERT_MESSAGE("Wrong ref data state.", !aRefData.IsRowRel() && !aRefData.IsColRel() && !aRefData.IsTabRel());
- ASSERT_EQUAL_TYPE(SCCOL, 4, aRefData.GetCol());
- ASSERT_EQUAL_TYPE(SCROW, 5, aRefData.GetRow());
- ASSERT_EQUAL_TYPE(SCTAB, 3, aRefData.GetTab());
-
- aRefData.SetRowRel(true);
- aRefData.SetColRel(true);
- aRefData.SetTabRel(true);
- aRefData.SetAddress(aAddr, aPos);
- ASSERT_EQUAL_TYPE(SCCOL, 2, aRefData.GetCol());
- ASSERT_EQUAL_TYPE(SCROW, 3, aRefData.GetRow());
- ASSERT_EQUAL_TYPE(SCTAB, 1, aRefData.GetTab());
+ ScSingleRefData aRef;
+ aRef.InitAddress(aAddr);
+ CPPUNIT_ASSERT_MESSAGE("Wrong ref data state.", !aRef.IsRowRel() && !aRef.IsColRel() && !aRef.IsTabRel());
+ ASSERT_EQUAL_TYPE(SCCOL, 4, aRef.GetCol());
+ ASSERT_EQUAL_TYPE(SCROW, 5, aRef.GetRow());
+ ASSERT_EQUAL_TYPE(SCTAB, 3, aRef.GetTab());
+
+ aRef.SetRowRel(true);
+ aRef.SetColRel(true);
+ aRef.SetTabRel(true);
+ aRef.SetAddress(aAddr, aPos);
+ ASSERT_EQUAL_TYPE(SCCOL, 2, aRef.GetCol());
+ ASSERT_EQUAL_TYPE(SCROW, 3, aRef.GetRow());
+ ASSERT_EQUAL_TYPE(SCTAB, 1, aRef.GetTab());
+
+ // Test extension of range reference.
+
+ ScComplexRefData aDoubleRef;
+ aDoubleRef.InitRange(ScRange(2,2,0,4,4,0));
+
+ aRef.InitAddress(ScAddress(6,5,0));
+
+ aDoubleRef.Extend(aRef, ScAddress());
+ ScRange aTest = aDoubleRef.toAbs(ScAddress());
+ CPPUNIT_ASSERT_MESSAGE("Wrong start position of extended range.", aTest.aStart == ScAddress(2,2,0));
+ CPPUNIT_ASSERT_MESSAGE("Wrong end position of extended range.", aTest.aEnd == ScAddress(6,5,0));
+
+ ScComplexRefData aDoubleRef2;
+ aDoubleRef2.InitRangeRel(ScRange(1,2,0,8,6,0), ScAddress(5,5,0));
+ aDoubleRef.Extend(aDoubleRef2, ScAddress(5,5,0));
+ aTest = aDoubleRef.toAbs(ScAddress(5,5,0));
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong start position of extended range.", aTest.aStart == ScAddress(1,2,0));
+ CPPUNIT_ASSERT_MESSAGE("Wrong end position of extended range.", aTest.aEnd == ScAddress(8,6,0));
}
namespace {