@Test
public void testToList() {

  int[] indices = new int[] { 0, 1, 4, 10, 6, 9, 11 };
  BitSet bitSet = new BitSet(20);
  for (int i: indices) {
    bitSet.set(i);
  }
  List<Boolean> list = BitSetUtils.toList(bitSet, bitSet.size());
  Assert.assertEquals(bitSet.size(), list.size());
  for (int i = 0; i < bitSet.size(); i++) {
    Assert.assertEquals(bitSet.get(i), list.get(i));
  }
  List<Boolean> shortList = BitSetUtils.toList(bitSet, 5);
  Assert.assertEquals(5, shortList.size());
  for (int i = 0; i < 5; i++) {
    Assert.assertEquals(bitSet.get(i), shortList.get(i));
  }
  List<Boolean> longList = BitSetUtils.toList(bitSet, bitSet.size() + 10);
  Assert.assertEquals(bitSet.size() + 10, longList.size());
  for (int i = 0; i < bitSet.size() + 10; i++) {
    Assert.assertEquals(bitSet.get(i), longList.get(i));
  }
  boolean exception = false;
  try {
    BitSetUtils.toList(bitSet, -2);
  } catch (IllegalArgumentException e) {
    exception = true;
  }
  Assert.assertTrue(exception);
}