mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind/java: support byte arrays.
Fixes golang/go#9338. Change-Id: I6e2af67cdf7f923963fa525b944613a91aac994e Reviewed-on: https://go-review.googlesource.com/1884 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package go;
|
||||
|
||||
import android.test.suitebuilder.annotation.Suppress;
|
||||
import android.test.MoreAsserts;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import go.testpkg.Testpkg;
|
||||
|
||||
@@ -52,6 +55,32 @@ public class SeqTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testByteArray() {
|
||||
for (int i = 0; i < 2048; i++) {
|
||||
if (i == 0) {
|
||||
byte[] got = Testpkg.BytesAppend(null, null);
|
||||
assertEquals("Bytes(null+null) should match", (byte[])null, got);
|
||||
got = Testpkg.BytesAppend(new byte[0], new byte[0]);
|
||||
assertEquals("Bytes(empty+empty) should match", (byte[])null, got);
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] want = new byte[i];
|
||||
new Random().nextBytes(want);
|
||||
|
||||
byte[] s1 = null;
|
||||
byte[] s2 = null;
|
||||
if (i > 0) {
|
||||
s1 = Arrays.copyOfRange(want, 0, 1);
|
||||
}
|
||||
if (i > 1) {
|
||||
s2 = Arrays.copyOfRange(want, 1, i);
|
||||
}
|
||||
byte[] got = Testpkg.BytesAppend(s1, s2);
|
||||
MoreAsserts.assertEquals("Bytes(len="+i+") should match", want, got);
|
||||
}
|
||||
}
|
||||
|
||||
public void testGoRefGC() {
|
||||
Testpkg.S s = Testpkg.New();
|
||||
runGC();
|
||||
|
||||
Reference in New Issue
Block a user