~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.tests/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/tests/datasets/table/TableEntryTest.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.tests.datasets.table;
2
2
 
 
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;
 
9
 
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;
5
 
 
6
 
import junit.framework.TestCase;
7
 
 
8
 
public class TableEntryTest extends TestCase {
9
 
        public TableEntryTest(String name) {
10
 
                super(name);
11
 
        }
12
 
 
13
 
        protected void setUp() throws Exception {
14
 
                super.setUp();
15
 
                
 
12
import org.junit.Before;
 
13
import org.junit.Test;
 
14
 
 
15
public class TableEntryTest {
 
16
 
 
17
        @Before
 
18
        public void setUp() {
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};
18
21
                entry.add(data);
19
 
                data = new Integer[] {new Integer(5), new Integer(1), new Integer(3)};
 
22
                data = new Integer[] {5, 1, 3};
20
23
                entry.add(data);
21
24
        }
22
25
        
 
26
        @Test
23
27
        public void testGetRowCount() {
24
28
                TableEntry entry2 = new TableEntry();
25
29
                assertEquals(0, entry2.getRowCount());
30
34
                
31
35
                assertEquals(2, entry.getRowCount());
32
36
        }
33
 
        
 
37
        @Test
34
38
        public void testGetColCount() {
35
39
                TableEntry entry2 = new TableEntry();
36
40
                assertEquals(0, entry2.getColCount());
41
45
                
42
46
                assertEquals(3, entry.getColCount());
43
47
        }
44
 
        
 
48
        @Test
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());
51
55
        }
52
 
        
 
56
        @Test
53
57
        public void testGetData() {
54
58
                assertEquals(data[0], entry.getData()[1][0]);
55
59
                assertEquals(data[1], entry.getData()[1][1]);
56
60
        }
57
 
 
 
61
        @Test
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));
63
67
 
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"));
68
72
        }
69
 
        
 
73
        @Test
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));
74
78
        }
75
 
        
 
79
        @Test
76
80
        public void testPutRow() {
77
 
                Integer[] data2 = new Integer[] {new Integer(2), new Integer(5)};
 
81
                Integer[] data2 = new Integer[] {2, 5};
78
82
                
79
83
                //Can't add to -1 position
80
84
                entry.putRow(-1, data2);
88
92
                assertEquals(2, entry.getRowCount());
89
93
 
90
94
                //Add successful
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());
94
98
        }
95
 
        
 
99
        @Test
96
100
        public void testAdd() {
97
 
                Integer[] data2 = new Integer[] {new Integer(2), new Integer(5)};
 
101
                Integer[] data2 = new Integer[] {2, 5};
98
102
                entry.add(data2);
99
103
                assertEquals(2, entry.getRowCount());
100
104
 
101
105
                //Add successful
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());
105
109
        }
106
 
        
 
110
        @Test
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]);
112
116
        }
113
 
        
 
117
        @Test
114
118
        public void testRemove() {
115
119
                assertTrue(entry.remove(0));
116
120
                assertEquals(1, entry.getRowCount());
117
121
        }
118
122
        
119
 
        protected void tearDown() throws Exception {
120
 
                super.tearDown();
121
 
        }
122
 
        
123
123
        TableEntry entry;
124
124
        Integer[] data;
125
125
}
 
 
b'\\ No newline at end of file'