@Test
public void toUnsignedShort() throws Exception {

    try {
        ByteArrayUtil.toUnsignedShort(null);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    Assert.assertEquals((int)0x1234, ByteArrayUtil.toUnsignedShort(new byte[] { (byte)0x12, (byte)0x34 }));
    Assert.assertEquals((int)0xFF56, ByteArrayUtil.toUnsignedShort(new byte[] { (byte)0x12, (byte)0xFF, (byte)0x56 }, 1, 2));
    Assert.assertEquals((int)61458, ByteArrayUtil.toUnsignedShort(new byte[] { (byte)0xF0, (byte)0x12 }));
    Assert.assertEquals((int)61458, ByteArrayUtil.toUnsignedShort(new byte[] { (byte)0x56, (byte)0xF0, (byte)0x12 }, 1, 2));
}