Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Fix #3720 #6218

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions android/guava-tests/test/com/google/common/primitives/BytesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
public class BytesTest extends TestCase {
private static final byte[] EMPTY = {};
private static final byte[] ARRAY1 = {(byte) 1};
private static final byte[] ARRAY2 = {(byte) 2};
private static final byte[] ARRAY2 = {(byte) 3};
private static final byte[] ARRAY4 = {(byte) 4};
private static final byte[] ARRAY23 = {(byte) 2, (byte) 3};
private static final byte[] ARRAY34 = {(byte) 3, (byte) 4};
private static final byte[] ARRAY234 = {(byte) 2, (byte) 3, (byte) 4};
private static final byte[] ARRAY234234 = {(byte) 2, (byte) 3, (byte) 4, (byte) 2, (byte) 3, (byte) 4};

private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

Expand Down Expand Up @@ -69,6 +75,30 @@ public void testIndexOf() {
.isEqualTo(1);
}

public void testIndexOf_fromIndex() {
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 10)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, -10)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 2, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 1, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 4)).isEqualTo(-1);

assertThat(Bytes.indexOf(ARRAY1, (byte) 1, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(new byte[] {(byte) -1}, (byte) -1, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 0)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 1)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 2)).isEqualTo(2);
}

public void testIndexOf_arrayTarget() {
assertThat(Bytes.indexOf(EMPTY, EMPTY)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, EMPTY)).isEqualTo(0);
Expand Down Expand Up @@ -103,6 +133,62 @@ public void testIndexOf_arrayTarget() {
.isEqualTo(-1);
}

public void testIndexOf_arrayTarget_fromIndex() {
ssertThat(Bytes.indexOf(EMPTY, EMPTY, 0)).isEqualTo(0);
ssertThat(Bytes.indexOf(EMPTY, EMPTY, 1)).isEqualTo(-1);
ssertThat(Bytes.indexOf(EMPTY, EMPTY, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(EMPTY, ARRAY234, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, -1)).isEqualTo(-1);

assertThat(Bytes.indexOf(ARRAY1, ARRAY1), 0).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1), 1).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1), 100).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1), -1).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234, EMPTY, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 2)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 0).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 1).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 3).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, -1).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, 0).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, 1).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, -1).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 0).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 1).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 3).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, -1).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 0).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 2).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 3).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, -1).isEqualTo(2);

assertThat(Bytes.indexOf(ARRAY234, ARRAY23, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY23, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY23, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, -1)).isEqualTo(1);

assertThat(Bytes.indexOf(ARRAY234, ARRAY234, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY234, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 1)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 2)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 3)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 4)).isEqualTo(-1);
}

public void testLastIndexOf() {
assertThat(Bytes.lastIndexOf(EMPTY, (byte) 1)).isEqualTo(-1);
assertThat(Bytes.lastIndexOf(ARRAY1, (byte) 2)).isEqualTo(-1);
Expand All @@ -115,6 +201,28 @@ public void testLastIndexOf() {
.isEqualTo(3);
}

public void testLastIndexOf_fromIndex() {
// empty case
assertThat(Bytes.indexOf(EMPTY, EMPTY, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 1)).isEqualTo(1);

// normal byte case
assertThat(Bytes.indexOf(ARRAY34, (byte) 4, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 1, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234234, (byte) 4, 1)).isEqualTo(5);

// byte list case
assertThat(Bytes.indexOf(ARRAY234234, ARRAY1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY23, 0)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 1)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 4)).isEqualTo(-1);
}

public void testConcat() {
assertThat(Bytes.concat()).isEqualTo(EMPTY);
assertThat(Bytes.concat(EMPTY)).isEqualTo(EMPTY);
Expand Down
102 changes: 102 additions & 0 deletions android/guava/src/com/google/common/primitives/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,41 @@ public static int indexOf(byte[] array, byte target) {
return indexOf(array, target, 0, array.length);
}

/**
* Returns the index of the first appearance of the value {@code target} in {@code array}.
*
* @param array an array of {@code byte} values, possibly empty
* @param target a primitive {@code byte} value
* @param fromIndex an index from which the searching occurs
* @return the least index {@code i} after {@code fromIndex} for which {@code array[i] == target}, or {@code -1} if no
* such index exists.
*/
public static int indexOf(byte[] array, byte target, int fromIndex) {
return indexOf(array, target, fromIndex, array.length);
}

/**
* Return the index of the last appearance of the value {@code target} in {@code array}
* from the index {@code fromIndex}, or {@code -1} if there is no such occurrence.
*
* @param array an array of {@code byte} values, possibly empty
* @param target a primitive {@code byte} value
* @param fromIndex an index from which the searching occurs
* @return the greatest index {@code i} for which {@code array[i] == target}, or {@code -1} if no
* such index exists.
*/
public static int lastIndexOf(byte[] array, byte target, int fromIndex){
checkNotNull(array, "array");
checkNotNull(target, "target");
checkNotNull(fromIndex,"fromIndex");
// check if fromIndex exceed the range
if(fromIndex > array.length-1 || fromIndex < 0){
return -1;
}

return lastIndexOf(array, target,fromIndex, array.length);
}

// TODO(kevinb): consider making this public
private static int indexOf(byte[] array, byte target, int start, int end) {
for (int i = start; i < end; i++) {
Expand Down Expand Up @@ -128,6 +163,73 @@ public static int indexOf(byte[] array, byte[] target) {
return -1;
}

/**
* Returns the start position of the first occurrence of the specified {@code target} within
* {@code array} from the index {@code fromIndex}, or {@code -1} if there is no such occurrence.
*
* @param array the array to search for the sequence {@code target}
* @param target the array to search for as a sub-sequence of {@code array}
* @param fromIndex the index from which to search from
*/
public static int indexOf(byte[] array, byte[] target, int fromIndex) {
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}

outer:
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 outer;
}
}
return i;
}
return -1;
}

/**
* Returns the first position of the last occurrence of the specified {@code
* target} within {@code array}, or {@code -1} if there is no such occurrence.
*
* @param array an array of {@code byte} values, possibly empty
* @param target the array to search for as a sub-sequence of {@code array}
* @param fromIndex an index from which the searching occurs
* @return the greatest index {@code i} for which {@code array[i] == target}, or {@code -1} if no
* such index exists.
*/
public static int lastIndexOf(byte[] array, byte[] target, int fromIndex){
checkNotNull(array, "array");
checkNotNull(target, "target");
checkNotNull(fromIndex,"fromIndex");

if (target.length == 0) {
return array.length - 1;
} else if (target.length > array.length) {
return -1;
}

int lastIndexOf = -1;
boolean differentValue;

for (int i = array.length-target.length ; i >= fromIndex; i--) {
differentValue = false;
for (int j = 0; j < target.length; j++) {
if (array[i + j] != target[j]) {
differentValue = true;
break;
}
}

if(!differentValue){
lastIndexOf = i;
}
}
return lastIndexOf;
}

/**
* Returns the index of the last appearance of the value {@code target} in {@code array}.
*
Expand Down
110 changes: 110 additions & 0 deletions guava-tests/test/com/google/common/primitives/BytesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
public class BytesTest extends TestCase {
private static final byte[] EMPTY = {};
private static final byte[] ARRAY1 = {(byte) 1};
private static final byte[] ARRAY2 = {(byte) 2};
private static final byte[] ARRAY3 = {(byte) 3};
private static final byte[] ARRAY4 = {(byte) 4};
private static final byte[] ARRAY23 = {(byte) 2, (byte) 3};
private static final byte[] ARRAY34 = {(byte) 3, (byte) 4};
private static final byte[] ARRAY234 = {(byte) 2, (byte) 3, (byte) 4};
private static final byte[] ARRAY234234 = {(byte) 2, (byte) 3, (byte) 4, (byte) 2, (byte) 3, (byte) 4};

private static final byte[] VALUES = {Byte.MIN_VALUE, -1, 0, 1, Byte.MAX_VALUE};

Expand Down Expand Up @@ -68,6 +74,30 @@ public void testIndexOf() {
assertThat(Bytes.indexOf(new byte[] {(byte) 2, (byte) 3, (byte) 2, (byte) 3}, (byte) 3))
.isEqualTo(1);
}

public void testIndexOf_fromIndex() {
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 10)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, -10)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 2, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 1, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 4)).isEqualTo(-1);

assertThat(Bytes.indexOf(ARRAY1, (byte) 1, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(new byte[] {(byte) -1}, (byte) -1, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, (byte) 2, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 0)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 1)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, (byte) 4, 2)).isEqualTo(2);
}

public void testIndexOf_arrayTarget() {
assertThat(Bytes.indexOf(EMPTY, EMPTY)).isEqualTo(0);
Expand Down Expand Up @@ -102,6 +132,64 @@ public void testIndexOf_arrayTarget() {
new byte[] {(byte) 2, (byte) 3, (byte) 4}))
.isEqualTo(-1);
}

public void testIndexOf_arrayTarget_fromIndex() {
assertThat(Bytes.indexOf(EMPTY, EMPTY, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(EMPTY, EMPTY, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, EMPTY, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(EMPTY, ARRAY234, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, -1)).isEqualTo(-1);

assertThat(Bytes.indexOf(ARRAY1, ARRAY1, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY1, ARRAY1, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234, EMPTY, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 2)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY1, -1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY2, -1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY3, -1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 0)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 2)).isEqualTo(2);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY4, -1)).isEqualTo(2);

assertThat(Bytes.indexOf(ARRAY234, ARRAY23, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY23, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY23, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY34, -1)).isEqualTo(1);

assertThat(Bytes.indexOf(ARRAY234, ARRAY234, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, ARRAY234, -1)).isEqualTo(0);

assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 0)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 1)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 2)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 3)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 4)).isEqualTo(-1);


}

public void testLastIndexOf() {
assertThat(Bytes.lastIndexOf(EMPTY, (byte) 1)).isEqualTo(-1);
Expand All @@ -115,6 +203,28 @@ public void testLastIndexOf() {
.isEqualTo(3);
}

public void testLastIndexOf_fromIndex() {
// empty case
assertThat(Bytes.indexOf(EMPTY, EMPTY, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, ARRAY234, 1)).isEqualTo(-1);
assertThat(Bytes.indexOf(EMPTY, (byte) 1, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 3)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, -1)).isEqualTo(0);
assertThat(Bytes.indexOf(ARRAY234, EMPTY, 1)).isEqualTo(1);

// normal byte case
assertThat(Bytes.indexOf(ARRAY34, (byte) 4, 0)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY1, (byte) 1, 2)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234, (byte) 3, 1)).isEqualTo(1);
assertThat(Bytes.indexOf(ARRAY234234, (byte) 4, 1)).isEqualTo(5);

// byte list case
assertThat(Bytes.indexOf(ARRAY234234, ARRAY1, 0)).isEqualTo(-1);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY23, 0)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 1)).isEqualTo(3);
assertThat(Bytes.indexOf(ARRAY234234, ARRAY234, 4)).isEqualTo(-1);
}

public void testConcat() {
assertThat(Bytes.concat()).isEqualTo(EMPTY);
assertThat(Bytes.concat(EMPTY)).isEqualTo(EMPTY);
Expand Down
Loading