From 689aa103903c205239354dd41c8838ccceaf1d84 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 23 Aug 2013 18:52:18 +0000 Subject: [PATCH] Add some explicit tests for column letter to/from number conversion git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1516978 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/util/TestCellReference.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/testcases/org/apache/poi/hssf/util/TestCellReference.java b/src/testcases/org/apache/poi/hssf/util/TestCellReference.java index 523a86bf6..2e1a775a0 100644 --- a/src/testcases/org/apache/poi/hssf/util/TestCellReference.java +++ b/src/testcases/org/apache/poi/hssf/util/TestCellReference.java @@ -26,6 +26,25 @@ import org.apache.poi.ss.SpreadsheetVersion; public final class TestCellReference extends TestCase { + public void testColNumConversion() { + assertEquals(0, CellReference.convertColStringToIndex("A")); + assertEquals(1, CellReference.convertColStringToIndex("B")); + assertEquals(25, CellReference.convertColStringToIndex("Z")); + assertEquals(26, CellReference.convertColStringToIndex("AA")); + assertEquals(27, CellReference.convertColStringToIndex("AB")); + assertEquals(51, CellReference.convertColStringToIndex("AZ")); + assertEquals(701, CellReference.convertColStringToIndex("ZZ")); + assertEquals(702, CellReference.convertColStringToIndex("AAA")); + assertEquals(18277, CellReference.convertColStringToIndex("ZZZ")); + + assertEquals("A", CellReference.convertNumToColString(0)); + assertEquals("B", CellReference.convertNumToColString(1)); + assertEquals("Z", CellReference.convertNumToColString(25)); + assertEquals("AA", CellReference.convertNumToColString(26)); + assertEquals("ZZ", CellReference.convertNumToColString(701)); + assertEquals("AAA", CellReference.convertNumToColString(702)); + assertEquals("ZZZ", CellReference.convertNumToColString(18277)); + } public void testAbsRef1(){ CellReference cf = new CellReference("$B$5");