@Test
public void setBitTest() {

    /*
        Set on
     */
    byte[] data = ByteBuffer.allocate(4).putInt(0).array();
    int posBit = 24;
    int expected = 16777216;
    int result = -1;
    byte[] ret = ByteUtil.setBit(data, posBit, 1);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
    posBit = 25;
    expected = 50331648;
    ret = ByteUtil.setBit(data, posBit, 1);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
    posBit = 2;
    expected = 50331652;
    ret = ByteUtil.setBit(data, posBit, 1);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
    /*
        Set off
     */
    posBit = 24;
    expected = 33554436;
    ret = ByteUtil.setBit(data, posBit, 0);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
    posBit = 25;
    expected = 4;
    ret = ByteUtil.setBit(data, posBit, 0);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
    posBit = 2;
    expected = 0;
    ret = ByteUtil.setBit(data, posBit, 0);
    result = ByteUtil.byteArrayToInt(ret);
    assertTrue(expected == result);
}