1
1
package org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.tests.datasets.table;
3
import static org.junit.Assert.assertArrayEquals;
4
import static org.junit.Assert.assertEquals;
5
import static org.junit.Assert.assertNotNull;
6
import static org.junit.Assert.assertNull;
7
import static org.junit.Assert.assertSame;
8
import static org.junit.Assert.assertTrue;
3
10
import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
4
11
import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.table.TableEntry;
6
import junit.framework.TestCase;
8
public class TableEntryTest extends TestCase {
9
public TableEntryTest(String name) {
13
protected void setUp() throws Exception {
12
import org.junit.Before;
13
import org.junit.Test;
15
public class TableEntryTest {
16
19
entry = new TableEntry();
17
data = new Integer[] {new Integer(2), new Integer(5), new Integer(4)};
20
data = new Integer[] {2, 5, 4};
19
data = new Integer[] {new Integer(5), new Integer(1), new Integer(3)};
22
data = new Integer[] {5, 1, 3};
23
27
public void testGetRowCount() {
24
28
TableEntry entry2 = new TableEntry();
25
29
assertEquals(0, entry2.getRowCount());
31
35
assertEquals(2, entry.getRowCount());
34
38
public void testGetColCount() {
35
39
TableEntry entry2 = new TableEntry();
36
40
assertEquals(0, entry2.getColCount());
42
46
assertEquals(3, entry.getColCount());
45
49
public void testGet() {
46
50
assertNull(entry.get(null, 1));
47
51
assertNull(entry.get("asdf", 1));
49
53
assertNull(entry.get(null, -1));
50
54
assertEquals("5", entry.get("2", 1).toString());
53
57
public void testGetData() {
54
58
assertEquals(data[0], entry.getData()[1][0]);
55
59
assertEquals(data[1], entry.getData()[1][1]);
58
62
public void testGetRow() {
59
63
assertNull(entry.getRow(10));
60
64
assertNull(entry.getRow(-1));
61
65
assertNotNull(entry.getRow(0));
62
assertEquals(data, entry.getRow(1));
66
assertArrayEquals(data, entry.getRow(1));
64
68
assertNull(entry.getRow(null));
65
69
assertNull(entry.getRow("asdf"));
66
70
assertNotNull(entry.getRow("2"));
67
assertEquals(data, entry.getRow("5"));
71
assertArrayEquals(data, entry.getRow("5"));
70
74
public void testGetColumn() {
71
75
assertEquals(data[1], entry.getColumn(1)[1]);
72
76
assertNull(entry.getColumn(10));
73
77
assertNull(entry.getColumn(-1));
76
80
public void testPutRow() {
77
Integer[] data2 = new Integer[] {new Integer(2), new Integer(5)};
81
Integer[] data2 = new Integer[] {2, 5};
79
83
//Can't add to -1 position
80
84
entry.putRow(-1, data2);
88
92
assertEquals(2, entry.getRowCount());
91
data2 = new Integer[] {new Integer(2), new Integer(5), new Integer(6)};
95
data2 = new Integer[] {2, 5, 6};
92
96
entry.putRow(0, data2);
93
97
assertEquals(2, entry.getRowCount());
96
100
public void testAdd() {
97
Integer[] data2 = new Integer[] {new Integer(2), new Integer(5)};
101
Integer[] data2 = new Integer[] {2, 5};
99
103
assertEquals(2, entry.getRowCount());
102
data2 = new Integer[] {new Integer(2), new Integer(5), new Integer(6)};
106
data2 = new Integer[] {2, 5, 6};
103
107
entry.add(data2);
104
108
assertEquals(3, entry.getRowCount());
107
111
public void testCopy() {
108
112
IDataEntry entry2 = entry.copy();
109
113
assertEquals(entry2.getRowCount(), entry.getRowCount());
110
114
assertEquals(entry2.getColCount(), entry.getColCount());
111
115
assertSame(entry2.getRow(0)[1], entry.getRow(0)[1]);
114
118
public void testRemove() {
115
119
assertTrue(entry.remove(0));
116
120
assertEquals(1, entry.getRowCount());
119
protected void tearDown() throws Exception {
123
123
TableEntry entry;
b'\\ No newline at end of file'