BitReader { public byte readBit() throws EOFException { byte result = testBit() ? (byte) 1 : (byte) 0; consumeBit(); return result; } BitReader(ByteBuf byteBuf); boolean testBit(); long readableBits(); void skipBits(int numberOfBits); byte readBit(); long readBits(int numberOfBits); boolean isByteBoundary(); Optional<Long> findStart();  }
@Test public void testReadBit() throws EOFException { ByteBuf byteBuf = Unpooled.wrappedBuffer(new byte[] {(byte) 0b10111010}); BitReader bitReader = new BitReader(byteBuf); assertThat(bitReader.readBit(), is((byte) 1)); assertThat(bitReader.readBit(), is((byte) 0)); assertThat(bitReader.readBit(), is((byte) 1)); assertThat(bitReader.readBit(), is((byte) 1)); assertThat(bitReader.readBit(), is((byte) 1)); assertThat(bitReader.readBit(), is((byte) 0)); assertThat(bitReader.readBit(), is((byte) 1)); assertThat(bitReader.readBit(), is((byte) 0)); }