@Test
public void testToIntVarLength() throws Exception {

    byte[] data = { (byte) 255, (byte) 128 };
    int length = 9; // num bits
    Assert.assertTrue(BitBufferHelper.getInt(data, length) == 384);
    byte[] data2 = { 0, 8 };
    Assert.assertTrue(BitBufferHelper.getInt(data2, 9) == 8);
    byte[] data3 = { 1, 1, 1 };
    Assert.assertTrue(BitBufferHelper.getInt(data3) == 65793);
    byte[] data4 = { 1, 1, 1 };
    Assert.assertTrue(BitBufferHelper.getInt(data4) == 65793);
    byte[] data5 = { 1, 1 };
    Assert.assertTrue(BitBufferHelper.getInt(data5) == 257);
}