### Question:
HexString implements Serializable { public static char[] toChars(byte[] bytes) { Assert.notNull(bytes, "Bytes must not be null"); return toChars(bytes, 0, bytes.length); } HexString(String hexString); private  HexString(byte[] bytes); byte[] getBytes(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); static HexString valueOf(byte[] bytes); static String toString(byte[] bytes); static String toString(byte[] bytes, int offset, int length); static char[] toChars(byte[] bytes); static char[] toChars(byte[] bytes, int offset, int length); static byte[] toBytes(String hexString);  }### Answer:
@Test public void shouldConvertToChars() throws Exception { char[] c = HexString.toChars(BYTES); assertThat(c, is(equalTo(STRING.toCharArray()))); }
@Test public void shouldCovertPartialToChars() throws Exception { assertThat(HexString.toChars(BYTES, 1, 2), is(equalTo("0102".toCharArray()))); assertThat(HexString.toChars(BYTES, BYTES.length - 1, 1), is(equalTo("FF".toCharArray()))); assertThat(HexString.toChars(BYTES, 0, 1), is(equalTo("00".toCharArray()))); }
@Test public void shouldNotAllowOffsetLessThanZeroForToChars() throws Exception { this.thrown.expect(IndexOutOfBoundsException.class); HexString.toChars(BYTES, -1, 2); }
@Test public void shouldNotAllowOffsetMoreThanNumberOfBytesForToChars() throws Exception { this.thrown.expect(IndexOutOfBoundsException.class); HexString.toChars(BYTES, BYTES.length + 1, 2); }
@Test public void shouldNotAllowLengthLessThanZeroForToChars() throws Exception { this.thrown.expect(IndexOutOfBoundsException.class); HexString.toChars(BYTES, 0, -1); }
@Test public void shouldNotAllowLengthMoreThanNumberOfBytesForToChars() throws Exception { this.thrown.expect(IndexOutOfBoundsException.class); HexString.toChars(BYTES, 1, BYTES.length); }
@Test public void shouldNotAllowNullBytesOnToChars() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("Bytes must not be null"); HexString.toChars(null); }