@Test public void equalIncreasingByteArray() { class TestCase { boolean mExpected; byte[] mArray; int mLength; int mStart; public TestCase(boolean expected, byte[] array, int length, int start) { mExpected = expected; mArray = array; mLength = length; mStart = start; } } ArrayList<TestCase> testCases = new ArrayList<>(); testCases.add(new TestCase(false, null, 0, 0)); testCases.add(new TestCase(true, new byte[] {}, 0, 0)); testCases.add(new TestCase(false, new byte[] {1}, 0, 0)); testCases.add(new TestCase(true, new byte[] {}, 0, 3)); testCases.add(new TestCase(false, new byte[] {1}, 0, 3)); testCases.add(new TestCase(true, new byte[] {0}, 1, 0)); testCases.add(new TestCase(false, new byte[] {1}, 1, 0)); testCases.add(new TestCase(true, new byte[] {0, 1, 2}, 3, 0)); testCases.add(new TestCase(false, new byte[] {0, 1, 2, (byte) 0xFF}, 3, 0)); testCases.add(new TestCase(false, new byte[] {1, 2, 3}, 3, 0)); testCases.add(new TestCase(true, new byte[] {3}, 1, 3)); testCases.add(new TestCase(false, new byte[] {2}, 1, 3)); testCases.add(new TestCase(true, new byte[] {3, 4, 5}, 3, 3)); testCases.add(new TestCase(false, new byte[] {3, 4, 5, (byte) 0xFF}, 3, 3)); testCases.add(new TestCase(false, new byte[] {2, 3, 4}, 3, 3)); for (TestCase testCase : testCases) { boolean result = BufferUtils.equalIncreasingByteArray(testCase.mStart, testCase.mLength, testCase.mArray); assertEquals(testCase.mExpected, result); } }
public static boolean equalIncreasingByteArray(int len, byte[] arr) { return equalIncreasingByteArray(0, len, arr); }
BufferUtils { public static boolean equalIncreasingByteArray(int len, byte[] arr) { return equalIncreasingByteArray(0, len, arr); } }
BufferUtils { public static boolean equalIncreasingByteArray(int len, byte[] arr) { return equalIncreasingByteArray(0, len, arr); } private  BufferUtils(); }
BufferUtils { public static boolean equalIncreasingByteArray(int len, byte[] arr) { return equalIncreasingByteArray(0, len, arr); } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position); }
BufferUtils { public static boolean equalIncreasingByteArray(int len, byte[] arr) { return equalIncreasingByteArray(0, len, arr); } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position);  }