diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-12-06 16:29:29 -0800 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-12-06 16:29:29 -0800 |
commit | 0a6fc5fad3cee99bf4da97214a2ca3deccc9b132 (patch) | |
tree | ac53bb8bfb492f97524b968ab1859dd9003c165e /tests | |
parent | e15f834a916d64b80a0da9cdc4ee0bd4439b6bf4 (diff) |
Truly fixed type cyclic refcounting.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/tests.c b/tests/tests.c index 3580c2e..5704292 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -239,7 +239,22 @@ static void test_upb_symtab() { upb_symtab_add_desc(s, descriptor, &status); ASSERT(upb_ok(&status)); upb_string_unref(descriptor); + + // Test cycle detection by making a cyclic def's main refcount go to zero + // and then be incremented to one again. + struct upb_string *symname = upb_strdupc("A"); + struct upb_def *def = upb_symtab_lookup(s, symname); + upb_string_unref(symname); + ASSERT(def); upb_symtab_unref(s); + struct upb_msgdef *m = upb_downcast_msgdef(def); + struct upb_fielddef *f = &m->fields[0]; + ASSERT(upb_hasdef(f)); + struct upb_def *def2 = f->def; + ASSERT(upb_downcast_msgdef(def2)); + upb_def_ref(def2); + upb_def_unref(def); + upb_def_unref(def2); } |