diff options
author | David North <dnorth@apache.org> | 2015-06-12 15:20:10 +0000 |
---|---|---|
committer | David North <dnorth@apache.org> | 2015-06-12 15:20:10 +0000 |
commit | 26dda73341d98dfec6026c72666640003832dcb1 (patch) | |
tree | 576d6308b779a5215ea71e660744efdb31abc96f /src/testcases/org/apache/poi/ss | |
parent | 0d55c0c7722b3eba58529f772dfbb53b2856415d (diff) | |
download | poi-26dda73341d98dfec6026c72666640003832dcb1.tar.gz poi-26dda73341d98dfec6026c72666640003832dcb1.zip |
My own patch to fix #56328
Add tests for initial patch applied by Nick in r1582892
Fix and test AreaReference#isWholeColumnReference to take account of the prevailing spreadsheet version. Fixing all users of this is a big undertaking, so for now I've left a fallback on the original behaviour for some cases.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1685101 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r-- | src/testcases/org/apache/poi/ss/util/TestAreaReference.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/util/TestAreaReference.java b/src/testcases/org/apache/poi/ss/util/TestAreaReference.java new file mode 100644 index 0000000000..43158038b1 --- /dev/null +++ b/src/testcases/org/apache/poi/ss/util/TestAreaReference.java @@ -0,0 +1,50 @@ +package org.apache.poi.ss.util; + +import org.apache.poi.ss.SpreadsheetVersion; + +import junit.framework.TestCase; + +/** + * Test for {@link AreaReference} handling of max rows. + * + * @author David North + */ +public class TestAreaReference extends TestCase { + + public void testWholeColumn() { + AreaReference oldStyle = AreaReference.getWholeColumn(SpreadsheetVersion.EXCEL97, "A", "B"); + assertEquals(0, oldStyle.getFirstCell().getCol()); + assertEquals(0, oldStyle.getFirstCell().getRow()); + assertEquals(1, oldStyle.getLastCell().getCol()); + assertEquals(SpreadsheetVersion.EXCEL97.getLastRowIndex(), oldStyle.getLastCell().getRow()); + assertTrue(oldStyle.isWholeColumnReference()); + + AreaReference oldStyleNonWholeColumn = new AreaReference("A1:B23", SpreadsheetVersion.EXCEL97); + assertFalse(oldStyleNonWholeColumn.isWholeColumnReference()); + + AreaReference newStyle = AreaReference.getWholeColumn(SpreadsheetVersion.EXCEL2007, "A", "B"); + assertEquals(0, newStyle.getFirstCell().getCol()); + assertEquals(0, newStyle.getFirstCell().getRow()); + assertEquals(1, newStyle.getLastCell().getCol()); + assertEquals(SpreadsheetVersion.EXCEL2007.getLastRowIndex(), newStyle.getLastCell().getRow()); + assertTrue(newStyle.isWholeColumnReference()); + + AreaReference newStyleNonWholeColumn = new AreaReference("A1:B23", SpreadsheetVersion.EXCEL2007); + assertFalse(newStyleNonWholeColumn.isWholeColumnReference()); + } + + public void testWholeRow() { + AreaReference oldStyle = AreaReference.getWholeRow(SpreadsheetVersion.EXCEL97, "1", "2"); + assertEquals(0, oldStyle.getFirstCell().getCol()); + assertEquals(0, oldStyle.getFirstCell().getRow()); + assertEquals(SpreadsheetVersion.EXCEL97.getLastColumnIndex(), oldStyle.getLastCell().getCol()); + assertEquals(1, oldStyle.getLastCell().getRow()); + + AreaReference newStyle = AreaReference.getWholeRow(SpreadsheetVersion.EXCEL2007, "1", "2"); + assertEquals(0, newStyle.getFirstCell().getCol()); + assertEquals(0, newStyle.getFirstCell().getRow()); + assertEquals(SpreadsheetVersion.EXCEL2007.getLastColumnIndex(), newStyle.getLastCell().getCol()); + assertEquals(1, newStyle.getLastCell().getRow()); + } + +} |