### Question:
ParsableBitArray { public int readBits(int numBits) { if (numBits == 0) { return 0; } int returnValue = 0; bitOffset += numBits; while (bitOffset > 8) { bitOffset -= 8; returnValue |= (data[byteOffset++] & 0xFF) << bitOffset; } returnValue |= (data[byteOffset] & 0xFF) >> (8 - bitOffset); returnValue &= 0xFFFFFFFF >>> (32 - numBits); if (bitOffset == 8) { bitOffset = 0; byteOffset++; } assertValidOffset(); return returnValue; } ParsableBitArray();  ParsableBitArray(byte[] data);  ParsableBitArray(byte[] data, int limit); void reset(byte[] data); void reset(ParsableByteArray parsableByteArray); void reset(byte[] data, int limit); int bitsLeft(); int getPosition(); int getBytePosition(); void setPosition(int position); void skipBit(); void skipBits(int numBits); boolean readBit(); int readBits(int numBits); void readBits(byte[] buffer, int offset, int numBits); void byteAlign(); void readBytes(byte[] buffer, int offset, int length); void skipBytes(int length); void putInt(int value, int numBits); public byte[] data; }### Answer:
@Test public void testReadBits() { assertThat(testArray.readBits(5)).isEqualTo(getTestDataBits(0, 5)); assertThat(testArray.readBits(0)).isEqualTo(getTestDataBits(5, 0)); assertThat(testArray.readBits(3)).isEqualTo(getTestDataBits(5, 3)); assertThat(testArray.readBits(16)).isEqualTo(getTestDataBits(8, 16)); assertThat(testArray.readBits(3)).isEqualTo(getTestDataBits(24, 3)); assertThat(testArray.readBits(18)).isEqualTo(getTestDataBits(27, 18)); assertThat(testArray.readBits(5)).isEqualTo(getTestDataBits(45, 5)); assertThat(testArray.readBits(14)).isEqualTo(getTestDataBits(50, 14)); }
@Test public void testRead32BitsByteAligned() { assertThat(testArray.readBits(32)).isEqualTo(getTestDataBits(0, 32)); assertThat(testArray.readBits(32)).isEqualTo(getTestDataBits(32, 32)); }
@Test public void testRead32BitsNonByteAligned() { assertThat(testArray.readBits(5)).isEqualTo(getTestDataBits(0, 5)); assertThat(testArray.readBits(32)).isEqualTo(getTestDataBits(5, 32)); }