aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-02-18 01:33:14 +0000
committerJaven O'Neal <onealj@apache.org>2016-02-18 01:33:14 +0000
commit9ee05a14528f38d37cbbf2f8d4af5554df60b30c (patch)
treefd1b8eadee3d5ad5d798addb38ed90c8bd95f4c7 /src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
parent8cbb571d9cb5d4853de66c4d48bac59a3c8022ec (diff)
downloadpoi-9ee05a14528f38d37cbbf2f8d4af5554df60b30c.tar.gz
poi-9ee05a14528f38d37cbbf2f8d4af5554df60b30c.zip
bug 56345: reject single-cell merged regions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730991 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
index 0dd2bc23f0..acc5ed4fb4 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
@@ -274,37 +274,59 @@ public abstract class BaseTestSheet {
final Workbook wb = _testDataProvider.createWorkbook();
final Sheet sheet = wb.createSheet();
- final CellRangeAddress baseRegion = new CellRangeAddress(0, 1, 0, 1);
+ final CellRangeAddress baseRegion = new CellRangeAddress(0, 1, 0, 1); //A1:B2
sheet.addMergedRegion(baseRegion);
try {
- final CellRangeAddress duplicateRegion = new CellRangeAddress(0, 1, 0, 1);
+ final CellRangeAddress duplicateRegion = new CellRangeAddress(0, 1, 0, 1); //A1:B2
sheet.addMergedRegion(duplicateRegion);
- fail("Should not be able to add a merged region if sheet already contains the same merged region");
+ fail("Should not be able to add a merged region (" + duplicateRegion.formatAsString() + ") " +
+ "if sheet already contains the same merged region (" + baseRegion.formatAsString() + ")");
} catch (final IllegalStateException e) { } //expected
try {
- final CellRangeAddress partiallyOverlappingRegion = new CellRangeAddress(1, 2, 1, 2);
+ final CellRangeAddress partiallyOverlappingRegion = new CellRangeAddress(1, 2, 1, 2); //B2:C3
sheet.addMergedRegion(partiallyOverlappingRegion);
- fail("Should not be able to add a merged region if it partially overlaps with an existing merged region");
+ fail("Should not be able to add a merged region (" + partiallyOverlappingRegion.formatAsString() + ") " +
+ "if it partially overlaps with an existing merged region (" + baseRegion.formatAsString() + ")");
} catch (final IllegalStateException e) { } //expected
try {
- final CellRangeAddress subsetRegion = new CellRangeAddress(0, 1, 0, 0);
+ final CellRangeAddress subsetRegion = new CellRangeAddress(0, 1, 0, 0); //A1:A2
sheet.addMergedRegion(subsetRegion);
- fail("Should not be able to add a merged region if it is a formal subset of an existing merged region");
+ fail("Should not be able to add a merged region (" + subsetRegion.formatAsString() + ") " +
+ "if it is a formal subset of an existing merged region (" + baseRegion.formatAsString() + ")");
} catch (final IllegalStateException e) { } //expected
try {
- final CellRangeAddress supersetRegion = new CellRangeAddress(0, 2, 0, 2);
+ final CellRangeAddress supersetRegion = new CellRangeAddress(0, 2, 0, 2); //A1:C3
sheet.addMergedRegion(supersetRegion);
- fail("Should not be able to add a merged region if it is a formal superset of an existing merged region");
+ fail("Should not be able to add a merged region (" + supersetRegion.formatAsString() + ") " +
+ "if it is a formal superset of an existing merged region (" + baseRegion.formatAsString() + ")");
} catch (final IllegalStateException e) { } //expected
final CellRangeAddress disjointRegion = new CellRangeAddress(10, 11, 10, 11);
sheet.addMergedRegion(disjointRegion); //allowed
}
+ /*
+ * Bug 56345: Reject single-cell merged regions
+ */
+ @Test
+ public void addMergedRegionWithSingleCellShouldFail() throws IOException {
+ final Workbook wb = _testDataProvider.createWorkbook();
+
+ final Sheet sheet = wb.createSheet();
+ final CellRangeAddress region = CellRangeAddress.valueOf("A1:A1");
+ try {
+ sheet.addMergedRegion(region);
+ fail("Should not be able to add a single-cell merged region (" + region.formatAsString() + ")");
+ } catch (final IllegalArgumentException e) {
+ // expected
+ }
+ wb.close();
+ }
+
/**
* Test adding merged regions. If the region's bounds are outside of the allowed range
* then an IllegalArgumentException should be thrown