@Test
public void testGetShort() throws Exception {

    byte[] data = new byte[2];
    data[0] = 7;
    data[1] = 8;
    int length = 9; // num bits
    Assert.assertTrue(BitBufferHelper.getShort(data, length) == 264);
    data[0] = 6;
    data[1] = 8;
    short result = BitBufferHelper.getShort(data, length);
    Assert.assertTrue(result == 8);
    data[0] = 8;
    data[1] = 47;
    result = BitBufferHelper.getShort(data, length);
    Assert.assertTrue(result == 47);
    // [0000 0001] [0001 0100] [0110 0100]
    byte[] data1 = new byte[2];
    data1[0] = 1;
    data1[1] = 20; // data1[2] = 100;
    length = 15;
    result = BitBufferHelper.getShort(data1, length);
    Assert.assertTrue(result == 276);
    byte[] data2 = new byte[2];
    data2[0] = 64;
    data2[1] = 99; // data2[2] = 100;
    length = 13;
    result = BitBufferHelper.getShort(data2, length);
    Assert.assertTrue(result == 99);
    byte[] data3 = { 100, 50 };
    result = BitBufferHelper.getShort(data3);
    Assert.assertTrue(result == 25650);
}