]> source.dussan.org Git - poi.git/commitdiff
Add some explicit tests for column letter to/from number conversion
authorNick Burch <nick@apache.org>
Fri, 23 Aug 2013 18:52:18 +0000 (18:52 +0000)
committerNick Burch <nick@apache.org>
Fri, 23 Aug 2013 18:52:18 +0000 (18:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1516978 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/util/TestCellReference.java

index 523a86bf6b0d73e6bb9a268336a5a5ce0bde99fb..2e1a775a08826bab81f79571e99ef3dc289e991d 100644 (file)
@@ -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");