ByteArrayUtils { public static boolean startsWith(byte[] source, byte[] match) { return startsWith(source, 0, match); } private  ByteArrayUtils(); static boolean startsWith(byte[] source, byte[] match); static boolean startsWith(byte[] source, int offset, byte[] match);  }
@Test(expected=NullPointerException.class) public void testStartsWithNullSource() throws Exception { ByteArrayUtils.startsWith(null, "str".getBytes(ENCODING_UTF8)); }
@Test(expected=NullPointerException.class) public void testStartsWithNullMatch() throws Exception { ByteArrayUtils.startsWith("str".getBytes(ENCODING_UTF8), null); }
@Test public void testStartsWith() throws Exception { assertFalse(ByteArrayUtils.startsWith( "strA".getBytes(ENCODING_UTF8), "strB".getBytes(ENCODING_UTF8))); assertTrue(ByteArrayUtils.startsWith( "strA".getBytes(ENCODING_UTF8), "str".getBytes(ENCODING_UTF8))); }
@Test public void testStartsWithOffset() throws Exception { assertFalse(ByteArrayUtils.startsWith( "prefix value".getBytes(ENCODING_UTF8), 6, "value".getBytes(ENCODING_UTF8))); assertTrue(ByteArrayUtils.startsWith( "prefix value".getBytes(ENCODING_UTF8), 7, "value".getBytes(ENCODING_UTF8))); assertFalse(ByteArrayUtils.startsWith( "prefix value".getBytes(ENCODING_UTF8), 8, "value".getBytes(ENCODING_UTF8))); }
@Test public void testStartsWithInvalidOffset() throws Exception { assertFalse(ByteArrayUtils.startsWith( "strA".getBytes(ENCODING_UTF8), Integer.MIN_VALUE, "str".getBytes(ENCODING_UTF8))); assertFalse(ByteArrayUtils.startsWith( "strA".getBytes(ENCODING_UTF8), Integer.MAX_VALUE, "str".getBytes(ENCODING_UTF8))); }