/** When a negative capacity is used, a {@link NegativeArraySizeException} should be thrown. */ @Test public void testNegativeArraySizeException() { BooleanBag bag = new BooleanBag(); for (int i = 0; i < 32; i++) { try { bag.ensureCapacity(-(1 << i)); } catch (NegativeArraySizeException ex) { if (ex.getClass() == NegativeArraySizeException.class) continue; } fail("NegativeArraySizeException expected for capacity " + (-(1 << i))); } }