aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-08-18 14:32:53 +0000
committerNick Burch <nick@apache.org>2015-08-18 14:32:53 +0000
commitbed2ee69c3222a58981280bd72533ef650dbb295 (patch)
tree69b0d413318faa9b3b57dd8f60bcb32c4894c881
parent025942c21be6752e1410f93259b7f959fd6d08ab (diff)
downloadpoi-bed2ee69c3222a58981280bd72533ef650dbb295.tar.gz
poi-bed2ee69c3222a58981280bd72533ef650dbb295.zip
Patch from Javen ONeal from bug #58252 - More CellReference unit testing coverage
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696427 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/testcases/org/apache/poi/hssf/util/TestCellReference.java2
-rw-r--r--src/testcases/org/apache/poi/ss/util/TestCellReference.java47
2 files changed, 46 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/util/TestCellReference.java b/src/testcases/org/apache/poi/hssf/util/TestCellReference.java
index 79fc876e93..d05c250d70 100644
--- a/src/testcases/org/apache/poi/hssf/util/TestCellReference.java
+++ b/src/testcases/org/apache/poi/hssf/util/TestCellReference.java
@@ -17,14 +17,12 @@
package org.apache.poi.hssf.util;
-
import junit.framework.TestCase;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellReference.NameType;
import org.apache.poi.ss.SpreadsheetVersion;
-
public final class TestCellReference extends TestCase {
public void testColNumConversion() {
assertEquals(0, CellReference.convertColStringToIndex("A"));
diff --git a/src/testcases/org/apache/poi/ss/util/TestCellReference.java b/src/testcases/org/apache/poi/ss/util/TestCellReference.java
index d8bfee77c4..a106e76e74 100644
--- a/src/testcases/org/apache/poi/ss/util/TestCellReference.java
+++ b/src/testcases/org/apache/poi/ss/util/TestCellReference.java
@@ -25,9 +25,54 @@ import junit.framework.TestCase;
/**
- * Tests that the common CellReference works as we need it to
+ * Tests that the common CellReference works as we need it to.
+ * Note - some additional testing is also done in the HSSF class,
+ * {@link org.apache.poi.hssf.util.TestCellReference}
*/
public final class TestCellReference extends TestCase {
+ public void testConstructors() {
+ CellReference cellReference;
+ final String sheet = "Sheet1";
+ final String cellRef = "A1";
+ final int row = 0;
+ final int col = 0;
+ final boolean absRow = true;
+ final boolean absCol = false;
+
+ cellReference = new CellReference(row, col);
+ assertEquals("A1", cellReference.formatAsString());
+
+ cellReference = new CellReference(row, col, absRow, absCol);
+ assertEquals("A$1", cellReference.formatAsString());
+
+ cellReference = new CellReference(row, (short)col);
+ assertEquals("A1", cellReference.formatAsString());
+
+ cellReference = new CellReference(cellRef);
+ assertEquals("A1", cellReference.formatAsString());
+
+ cellReference = new CellReference(sheet, row, col, absRow, absCol);
+ assertEquals("Sheet1!A$1", cellReference.formatAsString());
+ }
+
+ public void testFormatAsString() {
+ CellReference cellReference;
+
+ cellReference = new CellReference(null, 0, 0, false, false);
+ assertEquals("A1", cellReference.formatAsString());
+
+ //absolute references
+ cellReference = new CellReference(null, 0, 0, true, false);
+ assertEquals("A$1", cellReference.formatAsString());
+
+ //sheet name with no spaces
+ cellReference = new CellReference("Sheet1", 0, 0, true, false);
+ assertEquals("Sheet1!A$1", cellReference.formatAsString());
+
+ //sheet name with spaces
+ cellReference = new CellReference("Sheet 1", 0, 0, true, false);
+ assertEquals("'Sheet 1'!A$1", cellReference.formatAsString());
+ }
public void testGetCellRefParts() {
CellReference cellReference;