private void checkSize(int newcount) { if (newcount > bytes.length) { bytes = ArrayUtils.grow(bytes, newcount); } }
static byte[] grow(byte[] array, int minSize) { assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?"; if (array.length < minSize) { byte[] newArray = new byte[oversize(minSize, 1)]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } else return array; }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsLengthOOB() throws Exception { ArrayUtils.sliceEquals( new byte[]{0}, 0, 2, new byte[]{0}, 0, 1 ); }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsLengthOOB2() throws Exception { ArrayUtils.sliceEquals( new byte[]{0}, 0, 1, new byte[]{0}, 0, 2 ); }
static byte[] grow(byte[] array, int minSize) { assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?"; if (array.length < minSize) { byte[] newArray = new byte[oversize(minSize, 1)]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } else return array; }
private void checkSize(int newcount) { if (newcount > bytes.length) { bytes = ArrayUtils.grow(bytes, newcount); } }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsOffsetOOB() throws Exception { ArrayUtils.sliceEquals( new byte[]{0}, 1, 1, new byte[]{0}, 0, 1 ); }
static byte[] grow(byte[] array, int minSize) { assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?"; if (array.length < minSize) { byte[] newArray = new byte[oversize(minSize, 1)]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } else return array; }
private void checkSize(int newcount) { if (newcount > bytes.length) { bytes = ArrayUtils.grow(bytes, newcount); } }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsOffsetOOB2() throws Exception { ArrayUtils.sliceEquals( new byte[]{0}, 0, 1, new byte[]{0}, 1, 1 ); }
static byte[] grow(byte[] array, int minSize) { assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?"; if (array.length < minSize) { byte[] newArray = new byte[oversize(minSize, 1)]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } else return array; }
private void checkSize(int newcount) { if (newcount > bytes.length) { bytes = ArrayUtils.grow(bytes, newcount); } }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsOffsetLengthOOB() throws Exception { ArrayUtils.sliceEquals( new byte[]{0,1}, 1, 2, new byte[]{0,1}, 1, 1 ); }
static byte[] grow(byte[] array, int minSize) { assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?"; if (array.length < minSize) { byte[] newArray = new byte[oversize(minSize, 1)]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } else return array; }
private void checkSize(int newcount) { if (newcount > bytes.length) { bytes = ArrayUtils.grow(bytes, newcount); } }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void sliceEqualsOffsetLengthOOB2() throws Exception { ArrayUtils.sliceEquals( new byte[]{0,1}, 1, 1, new byte[]{0,1}, 1, 2 ); } }
@Test public void sliceEqualsIdentity() throws Exception { byte[] empty = new byte[0]; assertTrue(ArrayUtils.sliceEquals( empty, 0, 0, empty, 0, 0 )); }
@Test public void sliceEqualsNullEmpty() throws Exception { assertFalse(ArrayUtils.sliceEquals( null, 0, 0, new byte[0], 0, 0 )); }
@Test public void sliceEqualsSlicedMultiOffset() throws Exception { assertFalse(ArrayUtils.sliceEquals( new byte[]{10,10,2,3,0,0}, 1, 2, new byte[]{20,20,2,3,4,4}, 1, 2 )); }
@Test public void sliceEqualsMultiMulti() throws Exception { assertTrue(ArrayUtils.sliceEquals( new byte[]{0,1,2,3,4,5}, 0, 6, new byte[]{0,1,2,3,4,5}, 0, 6 )); }