seq, java: fix allocation bug in empty strings and test

Fixes golang/go#9271.

Change-Id: I57dcd11ae5afdc23bc9b1a0945d0789c9feeefb1
Reviewed-on: https://go-review.googlesource.com/1423
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw
2014-12-12 14:06:53 +00:00
parent 4ab8f01b53
commit f19599ac73
6 changed files with 60 additions and 13 deletions
+14
View File
@@ -38,6 +38,20 @@ public class SeqTest extends TestCase {
assertEquals("Strings should match", want, got);
}
public void testNilErr() throws Exception {
Testpkg.Err(null); // returns nil, no exception
}
public void testErr() {
String msg = "Go errors are dropped into the confusing space of exceptions";
try {
Testpkg.Err(msg);
fail("expected non-nil error to be turned into an exception");
} catch (Exception e) {
assertEquals("messages should match", msg, e.getMessage());
}
}
public void testGoRefGC() {
Testpkg.S s = Testpkg.New();
runGC();