BitReader { public boolean testBit() throws EOFException { if (currentByte == null) { if (byteBuf.readableBytes() < 1) { throw new EOFException("read past end-of-file"); } currentByte = byteBuf.readByte(); currentIndex = MAX_BIT_INDEX; } byte result = (byte) ((currentByte >> currentIndex) & 0b1); return result == 0b1; } BitReader(ByteBuf byteBuf); boolean testBit(); long readableBits(); void skipBits(int numberOfBits); byte readBit(); long readBits(int numberOfBits); boolean isByteBoundary(); Optional<Long> findStart();  }
@Test(expected = EOFException.class) public void testEOF() throws EOFException { ByteBuf byteBuf = Unpooled.wrappedBuffer(new byte[] {}); BitReader bitReader = new BitReader(byteBuf); bitReader.testBit(); }