summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-12-06 16:29:29 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-12-06 16:29:29 -0800
commit0a6fc5fad3cee99bf4da97214a2ca3deccc9b132 (patch)
treeac53bb8bfb492f97524b968ab1859dd9003c165e /tests
parente15f834a916d64b80a0da9cdc4ee0bd4439b6bf4 (diff)
Truly fixed type cyclic refcounting.
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.c15
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);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback