BitField implements Comparable<BitField> { public void clear() { for (int i = 0; i < bits.length; i++) { bits[i] = 0; } } 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 testClear() throws Exception { BitField b1 = new BitField(); assertEmpty(b1); b1.set(1); b1.clear(); assertEmpty(b1); Random r = new Random(0); int MAX_BIT = 100; int ITERATIONS = 40; for (int i=0; i<ITERATIONS; i++) { b1.set(r.nextInt(MAX_BIT)); } b1.clear(); assertEmpty(b1); }