001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.util;
019:
020: import junit.framework.TestCase;
021:
022: public class TestCellReference extends TestCase {
023: public TestCellReference(String s) {
024: super (s);
025: }
026:
027: public void testAbsRef1() {
028: CellReference cf = new CellReference("$B$5");
029: assertTrue("row is 4", cf.getRow() == 4);
030: assertTrue("col is 1", cf.getCol() == 1);
031: assertTrue("row is abs", cf.isRowAbsolute());
032: assertTrue("col is abs", cf.isColAbsolute());
033: assertTrue("string is $B$5", cf.toString().equals("$B$5"));
034: }
035:
036: public void testAbsRef2() {
037: CellReference cf = new CellReference(4, 1, true, true);
038: assertTrue("row is 4", cf.getRow() == 4);
039: assertTrue("col is 1", cf.getCol() == 1);
040: assertTrue("row is abs", cf.isRowAbsolute());
041: assertTrue("col is abs", cf.isColAbsolute());
042: assertTrue("string is $B$5", cf.toString().equals("$B$5"));
043: }
044:
045: public void testAbsRef3() {
046: CellReference cf = new CellReference("B$5");
047: assertTrue("row is 4", cf.getRow() == 4);
048: assertTrue("col is 1", cf.getCol() == 1);
049: assertTrue("row is abs", cf.isRowAbsolute());
050: assertTrue("col is rel", !cf.isColAbsolute());
051: assertTrue("string is B$5", cf.toString().equals("B$5"));
052: }
053:
054: public void testAbsRef4() {
055: CellReference cf = new CellReference(4, 1, true, false);
056: assertTrue("row is 4", cf.getRow() == 4);
057: assertTrue("col is 1", cf.getCol() == 1);
058: assertTrue("row is abs", cf.isRowAbsolute());
059: assertTrue("col is rel", !cf.isColAbsolute());
060: assertTrue("string is B$5", cf.toString().equals("B$5"));
061: }
062:
063: public void testAbsRef5() {
064: CellReference cf = new CellReference("$B5");
065: assertTrue("row is 4", cf.getRow() == 4);
066: assertTrue("col is 1", cf.getCol() == 1);
067: assertTrue("row is abs", !cf.isRowAbsolute());
068: assertTrue("col is rel", cf.isColAbsolute());
069: assertTrue("string is B$5", cf.toString().equals("$B5"));
070: }
071:
072: public void testAbsRef6() {
073: CellReference cf = new CellReference(4, 1, false, true);
074: assertTrue("row is 4", cf.getRow() == 4);
075: assertTrue("col is 1", cf.getCol() == 1);
076: assertTrue("row is abs", !cf.isRowAbsolute());
077: assertTrue("col is rel", cf.isColAbsolute());
078: assertTrue("string is B$5", cf.toString().equals("$B5"));
079: }
080:
081: public void testAbsRef7() {
082: CellReference cf = new CellReference("B5");
083: assertTrue("row is 4", cf.getRow() == 4);
084: assertTrue("col is 1", cf.getCol() == 1);
085: assertTrue("row is abs", !cf.isRowAbsolute());
086: assertTrue("col is rel", !cf.isColAbsolute());
087: assertTrue("string is B$5", cf.toString().equals("B5"));
088: }
089:
090: public void testAbsRef8() {
091: CellReference cf = new CellReference(4, 1, false, false);
092: assertTrue("row is 4", cf.getRow() == 4);
093: assertTrue("col is 1", cf.getCol() == 1);
094: assertTrue("row is abs", !cf.isRowAbsolute());
095: assertTrue("col is rel", !cf.isColAbsolute());
096: assertTrue("string is B$5", cf.toString().equals("B5"));
097: }
098:
099: public static void main(String[] args) {
100: System.out
101: .println("Testing org.apache.poi.hssf.util.TestCellReference");
102: junit.textui.TestRunner.run(TestCellReference.class);
103: }
104:
105: }
|