}
}
@Test
public void testCopyNRowsFromTableUsingIntIterator() {
Table tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(
this.table, this.table.rows(), Integer.MAX_VALUE, true);
assertTrue(tbl.getRowCount() == this.table.getRowCount());
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table,
this.table.rows(), Integer.MAX_VALUE, false);
assertTrue(tbl.getRowCount() == this.table.getRowCount());
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table,
this.table.rows(), 0, false);
assertTrue(tbl.getRowCount() == 0);
try {
TableUtilities.copyNRowsFromTableUsingIntIterator(this.table,
this.table.rows(), -100, false);
fail();
} catch (IllegalArgumentException e) {
// good, negative is not allowed
}
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table,
this.table.rows(), 3, true);
assertTrue(tbl.getRowCount() == 3);
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table,
this.table.rows(), 3, false);
assertTrue(tbl.getRowCount() == 3);
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table, this.table.rowsSortedBy("int", true), 1, true);
assertTrue(tbl.getRowCount() == 1);
assertTrue(tbl.get(0, "int").equals(9));
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table, this.table.rowsSortedBy("int", true), 1, false);
assertTrue(tbl.getRowCount() == 1);
assertTrue(tbl.get(0, "int").equals(0));
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table, this.table.rowsSortedBy("int", true), 3, true);
assertTrue(tbl.getRowCount() == 3);
assertTrue(tbl.get(0, "int").equals(9));
assertTrue(tbl.get(1, "int").equals(8));
assertTrue(tbl.get(2, "int").equals(7));
tbl = TableUtilities.copyNRowsFromTableUsingIntIterator(this.table, this.table.rowsSortedBy("int", true), 3, false);
assertTrue(tbl.getRowCount() == 3);
assertTrue(tbl.get(0, "int").equals(0));
assertTrue(tbl.get(1, "int").equals(1));
assertTrue(tbl.get(2, "int").equals(2));
}