Skip to content

Commit 6dfdf10

Browse files
authored
Merge pull request #138 from epics-base/unit_test_ivtable
Unit test for IVTable
2 parents 6d2c4f6 + 8dd2a22 commit 6dfdf10

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.epics.vtype;
2+
3+
import org.epics.util.array.ArrayDouble;
4+
import org.epics.util.array.ArrayFloat;
5+
import org.epics.util.array.ArrayInteger;
6+
import org.junit.Test;
7+
8+
import java.util.Arrays;
9+
10+
import static org.junit.Assert.assertEquals;
11+
import static org.junit.Assert.assertTrue;
12+
13+
public class VTableTest {
14+
15+
/**
16+
* ignore the types and labels when determining the column count
17+
*/
18+
@Test
19+
public void testIVTableColumnCount() {
20+
VTable vTable = new IVTable(Arrays.asList(VInt.class, VDouble.class),
21+
Arrays.asList("int"),
22+
Arrays.asList(ArrayInteger.of(1, 2, 3), ArrayDouble.of(1.0, 2.0, 3.0), ArrayFloat.of(1.0f, 2.0f, 3.0f)));
23+
24+
// Assert that column count is based on values data.
25+
assertEquals(3, vTable.getColumnCount());
26+
27+
assertEquals(3, vTable.getRowCount());
28+
assertTrue(vTable.getColumnType(0).isAssignableFrom(VInt.class));
29+
assertTrue(vTable.getColumnType(1).isAssignableFrom(VDouble.class));
30+
assertEquals("int", vTable.getColumnName(0));
31+
}
32+
33+
/**
34+
* NTTables support columns with different row counts, the table should return the max number of rows
35+
*/
36+
@Test
37+
public void testIVTableRowCount() {
38+
VTable vTable = new IVTable(Arrays.asList(),
39+
Arrays.asList("int"),
40+
Arrays.asList(ArrayInteger.of(1, 2, 3), ArrayDouble.of(1.0, 2.0), ArrayFloat.of(1.0f)));
41+
42+
assertEquals(3, vTable.getRowCount());
43+
}
44+
}

0 commit comments

Comments
 (0)