### Question:
ByteArrayUtils { public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (((int) bytes[offset]) << 16) + (((int) bytes[offset + 1]) << 8) + ((int) bytes[offset + 2]); }  static byte[] fromHex(String hex); static String toHex(byte[] byteArray); static int threeBytesToInt(byte[] bytes, int offset);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void threeBytesToInt_null() { int value = ByteArrayUtils.threeBytesToInt(null, 0); }
@Test(expected = IllegalArgumentException.class) public void threeBytesToInt_negative_offset() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_GOOD, -1); }
@Test(expected = IllegalArgumentException.class) public void threeBytesToInt_too_short_buffer_1() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_LEN_2, 0); }
@Test(expected = IllegalArgumentException.class) public void threeBytesToInt_too_short_buffer_2() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_LEN_3, 1); }
@Test public void threeBytesToInt_buffer_ok_1() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_LEN_3, 0); assertEquals(value, 0x123456); }
@Test public void threeBytesToInt_buffer_ok_2() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_GOOD, 0); assertEquals(value, 0x123456); }
@Test public void threeBytesToInt_buffer_ok_3() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_GOOD, 1); assertEquals(value, 0x345678); }
@Test public void threeBytesToInt_buffer_ok_4() { int value = ByteArrayUtils.threeBytesToInt(BYTEARRAY_GOOD, 13); assertEquals(value, 0x654321); }