@Test
public void toShort() throws Exception {

    try {
        ByteArrayUtil.toShort(null);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    try {
        ByteArrayUtil.toShort(new byte[] { (byte)0x12, (byte)0x34 }, 1, 3);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    try {
        ByteArrayUtil.toShort(new byte[] { (byte)0x12, (byte)0x34 }, 1, 2);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    Assert.assertEquals((short)0x1234, ByteArrayUtil.toShort(new byte[] { (byte)0x12, (byte)0x34 }));
    Assert.assertEquals((short)0x3456, ByteArrayUtil.toShort(new byte[] { (byte)0x12, (byte)0x34, (byte)0x56 }, 1, 2));
}