@Test
public void toUnsignedByte() throws Exception {

    try {
        ByteArrayUtil.toUnsignedByte(null);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    Assert.assertEquals((short)0x12, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12 }));
    Assert.assertEquals((short)0xFF, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12, (byte)0xFF, (byte)0x56 }, 1, 1));
    Assert.assertEquals((short)240, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0xF0 }));
    Assert.assertEquals((short)240, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12, (byte)0xF0 }, 1, 1));
}