ParsableBitArray { public long readBitsToLong(int numBits) { if (numBits <= 32) { return Util.toUnsignedLong(readBits(numBits)); } return Util.toLong(readBits(numBits - 32), readBits(32)); } 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); long readBitsToLong(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; }
@Test public void testReadBitsToLong0Bits() { byte[] testData = TestUtil.createByteArray(0x3C); ParsableBitArray testArray = new ParsableBitArray(testData); long result = testArray.readBitsToLong(0); assertThat(result).isEqualTo(0); }
@Test public void testReadBitsToLongNegativeValue() { byte[] testData = TestUtil.createByteArray(0xF0, 0, 0, 0, 0, 0, 0, 0); ParsableBitArray testArray = new ParsableBitArray(testData); long result = testArray.readBitsToLong(64); assertThat(result).isEqualTo(0xF000000000000000L); }