MCPcopy Create free account
hub / github.com/apache/qpid-proton / test_decref_order

Function test_decref_order

c/tests/refcount_test.cpp:221–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221static void test_decref_order(int *indexes, void **objects) {
222 setup(objects);
223
224 // printf("-----------\n");
225 for (int i = 0; i < 3; i++) {
226 int idx = indexes[i];
227 void *obj = objects[idx];
228 // printf("decreffing %s\n", pn_object_reify(obj)->name);
229 pn_decref(obj);
230 for (int j = 0; j <= i; j++) {
231 // everything we've decreffed already should have a refcount of
232 // 1 because it has been preserved by its parent
233 assert_refcount(objects[indexes[j]], 1);
234 }
235 for (int j = i + 1; j < 4; j++) {
236 // everything we haven't decreffed yet should have a refcount of
237 // 2 unless it has a descendant that has not been decrefed (or
238 // it has no child) in which case it should have a refcount of 1
239 int idx = indexes[j];
240 void *obj = objects[idx];
241 REQUIRE(!decreffed(indexes, objects, i, obj));
242 if (live_descendent(indexes, objects, i, idx)) {
243 assert_refcount(obj, 2);
244 } else {
245 assert_refcount(obj, 1);
246 }
247 }
248 }
249
250 void *last = objects[indexes[3]];
251 // printf("decreffing %s\n", pn_object_reify(last)->name);
252 pn_decref(last);
253 // all should be gone now, need to run with valgrind to check
254}
255
256static void permute(int n, int *indexes, void **objects) {
257 int j;

Callers 1

permuteFunction · 0.85

Calls 5

setupFunction · 0.85
pn_decrefFunction · 0.85
assert_refcountFunction · 0.85
decreffedFunction · 0.85
live_descendentFunction · 0.85

Tested by

no test coverage detected