View | Details | Raw Unified | Return to bug 58252
Collapse All | Expand All

(-)src/testcases/org/apache/poi/ss/util/TestCellReference.java (+43 lines)
Lines 28-34 Link Here
28
 * Tests that the common CellReference works as we need it to
28
 * Tests that the common CellReference works as we need it to
29
 */
29
 */
30
public final class TestCellReference extends TestCase {
30
public final class TestCellReference extends TestCase {
31
	public void testConstructors() {
32
		CellReference cellReference;
33
		final String sheet = "Sheet1";
34
		final String cellRef = "A1";
35
		final int row = 0;
36
		final int col = 0;
37
		final boolean absRow = true;
38
		final boolean absCol = false;
39
		
40
		cellReference = new CellReference(row, col);
41
		assertEquals("A1", cellReference.formatAsString());
42
		
43
		cellReference = new CellReference(row, col, absRow, absCol);
44
		assertEquals("A$1", cellReference.formatAsString());
45
		
46
		cellReference = new CellReference(row, (short)col);
47
		assertEquals("A1", cellReference.formatAsString());
48
		
49
		cellReference = new CellReference(cellRef);
50
		assertEquals("A1", cellReference.formatAsString());
51
		
52
		cellReference = new CellReference(sheet, row, col, absRow, absCol);
53
		assertEquals("Sheet1!A$1", cellReference.formatAsString());
54
	}
31
	
55
	
56
	public void testFormatAsString() {
57
		CellReference cellReference;
58
		
59
		cellReference = new CellReference(null, 0, 0, false, false);
60
		assertEquals("A1", cellReference.formatAsString());
61
		
62
		//absolute references
63
		cellReference = new CellReference(null, 0, 0, true, false);
64
		assertEquals("A$1", cellReference.formatAsString());
65
		
66
		//sheet name with no spaces
67
		cellReference = new CellReference("Sheet1", 0, 0, true, false);
68
		assertEquals("Sheet1!A$1", cellReference.formatAsString());
69
		
70
		//sheet name with spaces
71
		cellReference = new CellReference("Sheet 1", 0, 0, true, false);
72
		assertEquals("'Sheet 1'!A$1", cellReference.formatAsString());
73
	}
74
	
32
	public void testGetCellRefParts() {
75
	public void testGetCellRefParts() {
33
		CellReference cellReference;
76
		CellReference cellReference;
34
		String[] parts;
77
		String[] parts;

Return to bug 58252