diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-08-10 14:22:25 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-08-10 14:22:25 +0000 |
commit | d7dd7abf78685d5e797002190a5923b3221c2623 (patch) | |
tree | a405c9949d166ddd869a46e4f6d9d3919fe49988 | |
parent | df9bc05a945d9f164ec9e0673dde6b31ecb0e48c (diff) | |
download | poi-d7dd7abf78685d5e797002190a5923b3221c2623.tar.gz poi-d7dd7abf78685d5e797002190a5923b3221c2623.zip |
add test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892179 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java | 118 |
1 files changed, 79 insertions, 39 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java index e95a07d20d..483336aa79 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java @@ -396,44 +396,84 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { @Test void testChangeReference() throws IOException { - try (XSSFWorkbook wb = new XSSFWorkbook()) { - XSSFHyperlink hyperlink = new XSSFHyperlink(HyperlinkType.URL); - hyperlink.setCellReference("B2"); - assertEquals(1, hyperlink.getFirstRow()); - assertEquals(1, hyperlink.getLastRow()); - assertEquals(1, hyperlink.getFirstColumn()); - assertEquals(1, hyperlink.getLastColumn()); - hyperlink.setFirstRow(0); - assertEquals("B1:B2", hyperlink.getCellRef()); - assertEquals(0, hyperlink.getFirstRow()); - assertEquals(1, hyperlink.getLastRow()); - assertEquals(1, hyperlink.getFirstColumn()); - assertEquals(1, hyperlink.getLastColumn()); - hyperlink.setLastRow(2); - assertEquals("B1:B3", hyperlink.getCellRef()); - assertEquals(0, hyperlink.getFirstRow()); - assertEquals(2, hyperlink.getLastRow()); - assertEquals(1, hyperlink.getFirstColumn()); - assertEquals(1, hyperlink.getLastColumn()); - hyperlink.setFirstColumn(0); - assertEquals("A1:B3", hyperlink.getCellRef()); - assertEquals(0, hyperlink.getFirstRow()); - assertEquals(2, hyperlink.getLastRow()); - assertEquals(0, hyperlink.getFirstColumn()); - assertEquals(1, hyperlink.getLastColumn()); - hyperlink.setLastColumn(2); - assertEquals("A1:C3", hyperlink.getCellRef()); - assertEquals(0, hyperlink.getFirstRow()); - assertEquals(2, hyperlink.getLastRow()); - assertEquals(0, hyperlink.getFirstColumn()); - assertEquals(2, hyperlink.getLastColumn()); - hyperlink.setFirstColumn(2); - hyperlink.setFirstRow(2); - assertEquals("C3", hyperlink.getCellRef()); - assertEquals(2, hyperlink.getFirstRow()); - assertEquals(2, hyperlink.getLastRow()); - assertEquals(2, hyperlink.getFirstColumn()); - assertEquals(2, hyperlink.getLastColumn()); - } + XSSFHyperlink hyperlink = new XSSFHyperlink(HyperlinkType.URL); + hyperlink.setCellReference("B2"); + assertEquals(1, hyperlink.getFirstRow()); + assertEquals(1, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setFirstRow(0); + assertEquals("B1:B2", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(1, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setLastRow(2); + assertEquals("B1:B3", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setFirstColumn(0); + assertEquals("A1:B3", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(0, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setLastColumn(2); + assertEquals("A1:C3", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(0, hyperlink.getFirstColumn()); + assertEquals(2, hyperlink.getLastColumn()); + hyperlink.setFirstColumn(2); + hyperlink.setFirstRow(2); + assertEquals("C3", hyperlink.getCellRef()); + assertEquals(2, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(2, hyperlink.getFirstColumn()); + assertEquals(2, hyperlink.getLastColumn()); + } + + @Test + void testChangeRowsAndColumns() throws IOException { + XSSFHyperlink hyperlink = new XSSFHyperlink(HyperlinkType.URL); + hyperlink.setCellReference("B2"); + hyperlink.setLastRow(0); + assertEquals("B1", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(0, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setLastColumn(0); + assertEquals("A1", hyperlink.getCellRef()); + assertEquals(0, hyperlink.getFirstRow()); + assertEquals(0, hyperlink.getLastRow()); + assertEquals(0, hyperlink.getFirstColumn()); + assertEquals(0, hyperlink.getLastColumn()); + hyperlink.setFirstRow(1); + assertEquals("A2", hyperlink.getCellRef()); + assertEquals(1, hyperlink.getFirstRow()); + assertEquals(1, hyperlink.getLastRow()); + assertEquals(0, hyperlink.getFirstColumn()); + assertEquals(0, hyperlink.getLastColumn()); + hyperlink.setFirstColumn(1); + assertEquals("B2", hyperlink.getCellRef()); + assertEquals(1, hyperlink.getFirstRow()); + assertEquals(1, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setLastRow(2); + assertEquals("B2:B3", hyperlink.getCellRef()); + assertEquals(1, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(1, hyperlink.getLastColumn()); + hyperlink.setLastColumn(2); + assertEquals("B2:C3", hyperlink.getCellRef()); + assertEquals(1, hyperlink.getFirstRow()); + assertEquals(2, hyperlink.getLastRow()); + assertEquals(1, hyperlink.getFirstColumn()); + assertEquals(2, hyperlink.getLastColumn()); } } |