aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
diff options
context:
space:
mode:
authorDanny Mui <dmui@apache.org>2003-06-27 23:04:28 +0000
committerDanny Mui <dmui@apache.org>2003-06-27 23:04:28 +0000
commit72e18903be3a8ea98c6e096da539afaca01fb7d0 (patch)
tree6a915a8ae094dcea50f2e200dba2fcbe72548493 /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
parent992f457092bce0fef17f7945b19956c373246306 (diff)
downloadpoi-72e18903be3a8ea98c6e096da539afaca01fb7d0.tar.gz
poi-72e18903be3a8ea98c6e096da539afaca01fb7d0.zip
Round 2 with removing merged regions. The MergedRecords array would be emptied
when removing all the regions but the merged pointer was still being preserved. Kill the pointer if the record is removed from the list so things are golden again. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353166 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
index 66d475edc9..f021c5439b 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
@@ -276,6 +276,25 @@ public class TestHSSFSheet
assertEquals("Left over region should be starting at row 1", 1, region.getRowFrom());
sheet.removeMergedRegion(0);
+
+ assertEquals("there should be no merged regions left!", 0, sheet.getNumMergedRegions());
+
+ //an, add, remove, get(0) would null pointer
+ sheet.addMergedRegion(region);
+ assertEquals("there should now be one merged region!", 1, sheet.getNumMergedRegions());
+ sheet.removeMergedRegion(0);
+ assertEquals("there should now be zero merged regions!", 0, sheet.getNumMergedRegions());
+ //add it again!
+ region.setRowTo(4);
+
+ sheet.addMergedRegion(region);
+ assertEquals("there should now be one merged region!", 1, sheet.getNumMergedRegions());
+
+ //should exist now!
+ assertTrue("there isn't more than one merged region in there", 1 <= sheet.getNumMergedRegions());
+ region = sheet.getMergedRegionAt(0);
+ assertEquals("the merged row to doesnt match the one we put in ", 4, region.getRowTo());
+
}
public static void main(java.lang.String[] args) {