BitField implements Comparable<BitField> { protected void ensureSpace(int bytes) { if (bits.length < bytes) { bits = Arrays.copyOf(bits, bytes); } } BitField(); void set(int bit, boolean value); void set(int bit); void unset(int bit); boolean isSet(int bit); void ser(DataOutput out); int deser(DataInput in); int deser(byte[] bytes, int start); @Override int compareTo(BitField o); void clear(); String toString();  }
@Test public void ensureSpace() throws Exception { BitField f = new BitField(); assertEquals(0, f.getBackingArray().length); f.ensureSpace(0); assertEquals(0, f.getBackingArray().length); f.ensureSpace(1); assertEquals(1, f.getBackingArray().length); f.ensureSpace(0); assertEquals(1, f.getBackingArray().length); f.ensureSpace(3); assertEquals(3, f.getBackingArray().length); }