]> source.dussan.org Git - poi.git/commitdiff
Add unit-test from bug 56454 to show that the problem is fixed now
authorDominik Stadler <centic@apache.org>
Sun, 1 Nov 2020 17:59:33 +0000 (17:59 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 1 Nov 2020 17:59:33 +0000 (17:59 +0000)
Probably fixed as part of 64460 via r1883037.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1883055 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

index 389f909a97a62623bb170582e742d518e71be202..25a564c9173b4913db64d251512d396d4e1d42ab 100644 (file)
@@ -764,6 +764,38 @@ public abstract class BaseTestSheetShiftRows {
     }
 
 
+    @Test
+    public void checkMergedRegions56454() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+
+        // populate sheet cells
+        for (int i = 0; i < 10; i++) {
+            Row row = sheet.createRow(i);
+
+            for (int j = 0; j < 10; j++) {
+                Cell cell = row.createCell(j, CellType.STRING);
+
+                cell.setCellValue(i + "x" + j);
+            }
+        }
+
+        CellRangeAddress region1 = new CellRangeAddress(3, 6, 0, 1);
+        CellRangeAddress region2 = new CellRangeAddress(3, 6, 2, 3);
+
+        sheet.addMergedRegion(region1);
+        sheet.addMergedRegion(region2);
+
+        sheet.shiftRows(4, sheet.getLastRowNum(), 1);
+
+        // check, if all regions still start at row 3
+        for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
+            CellRangeAddress cr = sheet.getMergedRegion(i);
+
+            assertEquals(cr.getFirstRow(), 3);
+        }
+    }
+