### Question:
ByteUtil { public static int indexOf(byte[] array, byte[] target, int fromIndex) { if (array == null || target == null) { return -1; } if (fromIndex < 0 || (fromIndex > (array.length - target.length))) { return -1; } if (target.length == 0) { return fromIndex; } firstbyte: for (int i = fromIndex; i < array.length - target.length + 1; i++) { for (int j = 0; j < target.length; j++) { if (array[i + j] != target[j]) { continue firstbyte; } } return i; } return -1; }  static byte[][] split(byte[] source, byte[] separator); static byte[][] split(byte[] source, byte[] separator, int limit); static List<Range> splitRanges(byte[] source, byte[] separator); static List<Range> splitRanges(byte[] source, byte[] separator, int limit); static byte[] join(byte[] separator, byte[]... components); static int indexOf(byte[] array, byte[] target, int fromIndex); static byte[] safeCopy(byte[] source, int offset, int length); static long getValueAsLong(final byte[] key,
      final Map<byte[], byte[]> taskValues); static String getValueAsString(final byte[] key,
      final Map<byte[], byte[]> taskValues); static double getValueAsDouble(byte[] key,
      NavigableMap<byte[], byte[]> infoValues); static int getValueAsInt(byte[] key, Map<byte[], byte[]> infoValues);  }### Answer:
@Test public void testIndexOf() { byte[] array = Bytes.toBytes("quackattack"); byte[] a = Bytes.toBytes("a"); byte[] ack = Bytes.toBytes("ack"); byte[] empty = Bytes.toBytes(""); int index = ByteUtil.indexOf(array, null, 0); assertEquals(-1, index); index = ByteUtil.indexOf(null, ack, 0); assertEquals(-1, index); index = ByteUtil.indexOf(null, ack, 1); assertEquals(-1, index); index = ByteUtil.indexOf(array, ack, 100); assertEquals(-1, index); index = ByteUtil.indexOf(array, ack, 100); assertEquals(-1, index); index = ByteUtil.indexOf(array, a, array.length + 1); assertEquals(-1, index); index = ByteUtil.indexOf(array, ack, array.length + 1); assertEquals(-1, index); index = ByteUtil.indexOf(array, empty, array.length + 1); assertEquals(-1, index); index = ByteUtil.indexOf(array, empty, 100); assertEquals(-1, index); index = ByteUtil.indexOf(array, ack, -3); assertEquals(-1, index); index = ByteUtil.indexOf(array, empty, -3); assertEquals(-1, index); index = ByteUtil.indexOf(array, empty, 0); assertEquals(0, index); index = ByteUtil.indexOf(array, empty, 4); assertEquals(4, index); assertIndexOf(0, array, empty, 0); assertIndexOf(1, array, empty, 1); assertIndexOf(3, array, empty, 3); assertIndexOf(5, array, empty, 5); assertIndexOf(11, array, empty, 11); assertIndexOf(2, array, a, 0); assertIndexOf(2, array, a, 1); assertIndexOf(2, array, a, 2); assertIndexOf(5, array, a, 3); assertIndexOf(5, array, a, 4); assertIndexOf(2, array, ack, 0); assertIndexOf(2, array, ack, 1); assertIndexOf(2, array, ack, 2); assertIndexOf(8, array, ack, 3); assertIndexOf(8, array, ack, 4); assertIndexOf(8, array, ack, 8); }