1 2 17 18 package org.apache.poi.hssf.util; 19 20 21 import junit.framework.TestCase; 22 23 24 public class TestCellReference extends TestCase { 25 public TestCellReference(String s) { 26 super(s); 27 } 28 29 public void testAbsRef1(){ 30 CellReference cf = new CellReference("$B$5"); 31 assertTrue("row is 4",cf.getRow()==4); 32 assertTrue("col is 1",cf.getCol()==1); 33 assertTrue("row is abs",cf.isRowAbsolute()); 34 assertTrue("col is abs",cf.isColAbsolute()); 35 assertTrue("string is $B$5",cf.toString().equals("$B$5")); 36 } 37 38 public void testAbsRef2(){ 39 CellReference cf = new CellReference(4,1,true,true); 40 assertTrue("row is 4",cf.getRow()==4); 41 assertTrue("col is 1",cf.getCol()==1); 42 assertTrue("row is abs",cf.isRowAbsolute()); 43 assertTrue("col is abs",cf.isColAbsolute()); 44 assertTrue("string is $B$5",cf.toString().equals("$B$5")); 45 } 46 47 public void testAbsRef3(){ 48 CellReference cf = new CellReference("B$5"); 49 assertTrue("row is 4",cf.getRow()==4); 50 assertTrue("col is 1",cf.getCol()==1); 51 assertTrue("row is abs",cf.isRowAbsolute()); 52 assertTrue("col is rel",!cf.isColAbsolute()); 53 assertTrue("string is B$5",cf.toString().equals("B$5")); 54 } 55 56 public void testAbsRef4(){ 57 CellReference cf = new CellReference(4,1,true,false); 58 assertTrue("row is 4",cf.getRow()==4); 59 assertTrue("col is 1",cf.getCol()==1); 60 assertTrue("row is abs",cf.isRowAbsolute()); 61 assertTrue("col is rel",!cf.isColAbsolute()); 62 assertTrue("string is B$5",cf.toString().equals("B$5")); 63 } 64 65 public void testAbsRef5(){ 66 CellReference cf = new CellReference("$B5"); 67 assertTrue("row is 4",cf.getRow()==4); 68 assertTrue("col is 1",cf.getCol()==1); 69 assertTrue("row is abs",!cf.isRowAbsolute()); 70 assertTrue("col is rel",cf.isColAbsolute()); 71 assertTrue("string is B$5",cf.toString().equals("$B5")); 72 } 73 74 public void testAbsRef6(){ 75 CellReference cf = new CellReference(4,1,false,true); 76 assertTrue("row is 4",cf.getRow()==4); 77 assertTrue("col is 1",cf.getCol()==1); 78 assertTrue("row is abs",!cf.isRowAbsolute()); 79 assertTrue("col is rel",cf.isColAbsolute()); 80 assertTrue("string is B$5",cf.toString().equals("$B5")); 81 } 82 83 public void testAbsRef7(){ 84 CellReference cf = new CellReference("B5"); 85 assertTrue("row is 4",cf.getRow()==4); 86 assertTrue("col is 1",cf.getCol()==1); 87 assertTrue("row is abs",!cf.isRowAbsolute()); 88 assertTrue("col is rel",!cf.isColAbsolute()); 89 assertTrue("string is B$5",cf.toString().equals("B5")); 90 } 91 92 public void testAbsRef8(){ 93 CellReference cf = new CellReference(4,1,false,false); 94 assertTrue("row is 4",cf.getRow()==4); 95 assertTrue("col is 1",cf.getCol()==1); 96 assertTrue("row is abs",!cf.isRowAbsolute()); 97 assertTrue("col is rel",!cf.isColAbsolute()); 98 assertTrue("string is B$5",cf.toString().equals("B5")); 99 } 100 101 102 public static void main(String [] args) { 103 System.out.println("Testing org.apache.poi.hssf.util.TestCellReference"); 104 junit.textui.TestRunner.run(TestCellReference.class); 105 } 106 107 } 108 | Popular Tags |