### Question:
BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); void set(int position); void setAll(); boolean get(int position); int size();  }### Answer:
@Test public void exceptionIfSetWithNegativePosition() { BitSet set = new BitSet(17); try { set.set(-1); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: -1, Size: 17", ex.getMessage()); } }
@Test public void exceptionIfSetWithOutOfBoundPosition() { BitSet set = new BitSet(17); try { set.set(17); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: 17, Size: 17", ex.getMessage()); } }