KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > util > TestCellReference


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

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 JavaDoc 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 JavaDoc [] 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