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:
Hyang-Ah Hana Kim
2014-12-19 20:07:11 +00:00
parent 1aa04cf038
commit b2e453e1cd
10 changed files with 182 additions and 22 deletions
+29
View File
@@ -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();