@Test
public void testToByteArrayInt() {

    int[] sarr4 = {0xCAFEBABE, 0xDEADBEEF};
    int[] sarr3 = {0xCAFEBA, 0xDEADBE};
    int[] sarr2 = {0xCAFE, 0xDEAD};
    int[] sarr1 = {0xCA, 0xFE, 0xBA, 0xBE};
    Assert.assertArrayEquals(Bytes.toByteArray(sarr4, sarr4.length, 4, true),
            Bytes.toByteArray(0xCA, 0xFE, 0xBA, 0xBE, 0xDE, 0xAD, 0xBE, 0xEF));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr4, sarr4.length, 4, false),
            Bytes.toByteArray(0xBE, 0xBA, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr3, sarr3.length, 3, true),
            Bytes.toByteArray(0xCA, 0xFE, 0xBA, 0xDE, 0xAD, 0xBE));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr3, sarr3.length, 3, false),
            Bytes.toByteArray(0xBA, 0xFE, 0xCA, 0xBE, 0xAD, 0xDE));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr2, sarr2.length, 2, true),
            Bytes.toByteArray(0xCA, 0xFE, 0xDE, 0xAD));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr2, sarr2.length, 2, false),
            Bytes.toByteArray(0xFE, 0xCA, 0xAD, 0xDE));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr1, sarr1.length, 1, true),
            Bytes.toByteArray(0xCA, 0xFE, 0xBA, 0xBE));
    Assert.assertArrayEquals(Bytes.toByteArray(sarr1, sarr1.length, 1, false),
            Bytes.toByteArray(0xCA, 0xFE, 0xBA, 0xBE));
}