public void testCurrentWidthOutOfRange() {
// Current width below minimum width
{
// Create some column info
List<ColumnWidthInfo> columns = new ArrayList<ColumnWidthInfo>();
columns.add(new ColumnWidthInfo(200, 300, 250, 0));
columns.add(new ColumnWidthInfo(200, 300, 50, 50));
columns.add(new ColumnWidthInfo(200, 300, 350, 199));
// Distribute some width
ColumnResizer resizer = new ColumnResizer();
int remaining = resizer.distributeWidth(columns, 0);
assertEquals(-351, remaining);
// Check outputs
assertEquals(200, columns.get(0).getNewWidth());
assertEquals(200, columns.get(1).getNewWidth());
assertEquals(200, columns.get(2).getNewWidth());
}
// Current width above maximum width
{
// Create some column info
List<ColumnWidthInfo> columns = new ArrayList<ColumnWidthInfo>();
columns.add(new ColumnWidthInfo(200, 300, 250, 350));
columns.add(new ColumnWidthInfo(200, 300, 50, 1000));
columns.add(new ColumnWidthInfo(200, 300, 350, 301));
// Distribute some width
ColumnResizer resizer = new ColumnResizer();
int remaining = resizer.distributeWidth(columns, 0);
assertEquals(751, remaining);