Skip to content

Commit 9bde616

Browse files
awalter17imagejan
authored andcommitted
Add tests for inserting a row/column to ResultsTable
1 parent 08f1fa5 commit 9bde616

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/test/java/net/imagej/table/DefaultResultsTableTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ public void testRemoveColumn() {
134134
checkTableModifiedColumn(table, null, 0);
135135
}
136136

137+
@Test
138+
public void testInsertColumn() {
139+
final ResultsTable table = createTable();
140+
final Double[] values = { -0.25, 0.5, 0.625, -1.25, 0.0, 0.0325, 100.5,
141+
13.25, 110.5, -2.25, 4.625, -3.0, 100.0, 1209.25, -10.5, 16.25, -200.0,
142+
-0.0325, 940385034958.5, -301284390284.25, 17.25 };
143+
144+
final DoubleColumn col = table.insertColumn(1, "Header4");
145+
col.fill(values);
146+
147+
assertEquals(table.getColumnCount(), 4);
148+
assertEquals(table.get(1).getHeader(), "Header4");
149+
150+
checkTableModifiedColumn(table, values, 1);
151+
}
152+
137153
@Test
138154
public void testAppendRow() {
139155
final ResultsTable table = createTable();
@@ -164,6 +180,21 @@ public void testRemoveRow() {
164180
checkTableModifiedRow(table, null, 4);
165181
}
166182

183+
@Test
184+
public void testRowInsert() {
185+
final ResultsTable table = createTable();
186+
final double[] values = { 1999, 42, 0.0 };
187+
188+
table.insertRow(6);
189+
190+
assertEquals(table.getRowCount(), 22);
191+
for (int i = 0; i < table.getColumnCount(); i++) {
192+
table.setValue(i, 6, values[i]);
193+
}
194+
195+
checkTableModifiedRow(table, values, 6);
196+
}
197+
167198
//TODO - Add more tests.
168199

169200
// -- Helper methods --

0 commit comments

Comments
 (0)