mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
mobile/bind: fix RefMap invariant
RefMap tracks its number of live Ref instances in the 'live' member. However, when a reference was removed and later added, 'live' wasn't updated accordingly. Fix and add a test. Change-Id: I806e17ea0319d76db4d07b5f8d9107b146ee80db Reviewed-on: https://go-review.googlesource.com/19975 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
@@ -33,6 +33,22 @@ public class SeqTest extends InstrumentationTestCase {
|
||||
assertEquals("const Log2E", 1/0.693147180559945309417232121458176568075500134360255254120680009, Testpkg.Log2E, 0.0001);
|
||||
}
|
||||
|
||||
public void testRefMap() {
|
||||
// Ensure that the RefMap.live count is kept in sync
|
||||
// even a particular reference number is removed and
|
||||
// added again
|
||||
Seq.RefMap m = new Seq.RefMap();
|
||||
Seq.Ref r = new Seq.Ref(1, null);
|
||||
m.put(r.refnum, r);
|
||||
m.remove(r.refnum);
|
||||
m.put(r.refnum, r);
|
||||
// Force the RefMap to grow, to activate the sanity
|
||||
// checking of the live count in RefMap.grow.
|
||||
for (int i = 2; i < 24; i++) {
|
||||
m.put(i, new Seq.Ref(i, null));
|
||||
}
|
||||
}
|
||||
|
||||
public void testVar() {
|
||||
assertEquals("var StringVar", "a string var", Testpkg.getStringVar());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user