@Test
public void toLong() throws Exception {

    try {
        ByteArrayUtil.toLong(null);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
    Assert.assertEquals(0x1234567812345678L, ByteArrayUtil.toLong(new byte[] { (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78, (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78 }));
    Assert.assertEquals(0x3456789012345678L, ByteArrayUtil.toLong(new byte[] { (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78, (byte)0x90, (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78 }, 1, 8));
}