BitVectorImpl implements BitVector, Iterable<Boolean> { @Override public long size() { return this.size; } BitVectorImpl();  BitVectorImpl(BitVector bitVector);  BitVectorImpl(long initialSize); @Override boolean addBit(boolean bit); @Override boolean equals(Object obj); @Override boolean getBit(long position); @Override int hashCode(); @Override Iterator<Boolean> iterator(); @Override void setBit(long position, boolean bit); @Override long size(); @Override String toString();  }
@Test public void testSize() { { BitVectorImpl bv = new BitVectorImpl(0x100); Assert.assertEquals(0x100, bv.size()); bv.addBit(false); bv.addBit(true); Assert.assertEquals(0x102, bv.size()); } { BitVectorImpl bv = new BitVectorImpl(); Assert.assertEquals(0, bv.size()); for (int i = 0; i < 0x300; i++) { bv.addBit((i % 5) == 0); Assert.assertEquals(i + 1, bv.size()); } } }