1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* This library is free software; you can redistribute it and/or modify it
10
* under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or
12
* (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
27
* --------------------
28
* ObjectTableTests.java
29
* --------------------
30
* (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
32
* Original Author: David Gilbert (for Object Refinery Limited);
35
* $Id: ObjectTableTests.java,v 1.5 2005/10/18 13:25:14 mungady Exp $
39
* 29-Apr-2003 : Version 1 (DG);
43
package org.jfree.util.junit;
45
import java.awt.Color;
47
import junit.framework.Test;
48
import junit.framework.TestCase;
49
import junit.framework.TestSuite;
51
import org.jfree.util.ObjectTable;
54
* Tests for the {@link ObjectTable} class.
56
public class ObjectTableTests extends TestCase {
61
public class TObjectTable extends ObjectTable {
66
public TObjectTable() {
71
* Returns the object from a particular cell in the table.
72
* Returns null, if there is no object at the given position.
74
* @param row the row index (zero-based).
75
* @param column the column index (zero-based).
79
public Object getObject(final int row, final int column) {
80
return super.getObject(row, column);
84
* Sets the object for a cell in the table. The table is expanded if necessary.
86
* @param row the row index (zero-based).
87
* @param column the column index (zero-based).
88
* @param object the object.
90
public void setObject(final int row, final int column, final Object object) {
91
super.setObject(row, column, object);
96
* Returns the tests as a test suite.
98
* @return The test suite.
100
public static Test suite() {
101
return new TestSuite(ObjectTableTests.class);
105
* Constructs a new set of tests.
107
* @param name the name of the tests.
109
public ObjectTableTests(final String name) {
114
* When an ObjectTable is created, it should be empty and return null for all lookups.
116
public void testCreate() {
118
final TObjectTable t = new TObjectTable();
120
// the new table should have zero rows and zero columns...
121
assertEquals(t.getColumnCount(), 0);
122
assertEquals(t.getRowCount(), 0);
124
// ...and should return null for any lookup
125
assertNull(t.getObject(0, 0));
126
assertNull(t.getObject(12, 12));
131
* When an object is added to the table outside the current bounds, the table
132
* should resize automatically.
134
public void testSetObject1() {
136
final TObjectTable t = new TObjectTable();
137
t.setObject(8, 5, Color.red);
138
assertEquals(6, t.getColumnCount());
139
assertEquals(9, t.getRowCount());
140
assertNull(t.getObject(7, 4));
141
assertEquals(Color.red, t.getObject(8, 5));