public static long readLengthCodedBinary(byte[] data, int index) throws IOException {
        int firstByte = data[index] & 0xFF;
        switch (firstByte) {
            case 251:
                return NULL_LENGTH;
            case 252:
                return readUnsignedShortLittleEndian(data, index + 1);
            case 253:
                return readUnsignedMediumLittleEndian(data, index + 1);
            case 254:
                return readUnsignedLongLittleEndian(data, index + 1);
            default:
                return firstByte;
        }
    }
@Test
	public void testReadLengthCodedBinary() throws IOException {
		Assert.assertEquals(0L,
			ByteHelper.readLengthCodedBinary(new byte[] {0}, 0));
		Assert.assertEquals(-1L,
			ByteHelper.readLengthCodedBinary(new byte[] {-5, -1, -7, 4, -7}, 0));
		Assert.assertEquals(65_021L,
			ByteHelper.readLengthCodedBinary(new byte[] {-3, -3, -3, 0, -3}, 0));
		Assert.assertEquals(37_119L,
			ByteHelper.readLengthCodedBinary(new byte[] {-4, -1, -112, 1, -112}, 0));
	}