Change to C99 and add weak references
This commit is contained in:
@ -113,6 +113,42 @@ int main(int argc, const char **argv) {
|
||||
|
||||
assert(refcount_context_garbage_collect(c) == 26);
|
||||
|
||||
a = make_a(c, 0, "a");
|
||||
|
||||
RefcountWeakref *w = refcount_context_make_weakref(c, a);
|
||||
assert(w);
|
||||
assert(refcount_context_num_refs(c, a) == 0);
|
||||
|
||||
b = refcount_context_strengthen(c, w);
|
||||
assert(b);
|
||||
assert(a == b);
|
||||
assert(refcount_context_num_refs(c, a) == 1);
|
||||
|
||||
refcount_context_ref(c, a);
|
||||
assert(refcount_context_num_refs(c, a) == 2);
|
||||
|
||||
RefcountWeakref *x = refcount_context_weaken(c, a);
|
||||
w = refcount_context_make_weakref(c, a);
|
||||
assert(refcount_context_num_refs(c, a) == 1);
|
||||
assert(w != x);
|
||||
refcount_context_destroy_weakref(c, x);
|
||||
|
||||
refcount_context_ref(c, a);
|
||||
assert(refcount_context_num_refs(c, a) == 2);
|
||||
|
||||
x = refcount_context_weaken(c, a);
|
||||
assert(refcount_context_num_refs(c, a) == 1);
|
||||
assert(w != x);
|
||||
assert(refcount_context_weakref_is_valid(c, w));
|
||||
assert(refcount_context_weakref_is_valid(c, x));
|
||||
|
||||
assert(!refcount_context_unref(c, a));
|
||||
assert(!refcount_context_weakref_is_valid(c, w));
|
||||
assert(!refcount_context_weakref_is_valid(c, x));
|
||||
|
||||
refcount_context_destroy_weakref(c, w);
|
||||
refcount_context_destroy_weakref(c, x);
|
||||
|
||||
refcount_context_destroy(c);
|
||||
|
||||
check_allocator_status();
|
||||
|
Reference in New Issue
Block a user