Skip to content

Commit

Permalink
Added test case for verification
Browse files Browse the repository at this point in the history
  • Loading branch information
deepikabhavnani authored and geky committed Aug 4, 2019
1 parent 74928f2 commit 0a84f94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void equeue_destroy(equeue_t *q) {
}
}
if (es->dtor) {
es->dtor(es + 1);
es->dtor(es + 1);
}
}
// notify background timer
Expand Down
24 changes: 23 additions & 1 deletion tests/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,28 @@ void break_request_cleared_on_timeout(void) {
equeue_destroy(&q);
}

void sibling_test(void) {
equeue_t q;
int err = equeue_create(&q, 1024);
test_assert(!err);

int id0 = equeue_call_in(&q, 1, pass_func, 0);
int id1 = equeue_call_in(&q, 1, pass_func, 0);
int id2 = equeue_call_in(&q, 1, pass_func, 0);

struct equeue_event *e = q.queue;

for (; e; e = e->next) {
for (struct equeue_event *s = e->sibling; s; s = s->sibling) {
test_assert(!s->next);
}
}
equeue_cancel(&q, id0);
equeue_cancel(&q, id1);
equeue_cancel(&q, id2);
equeue_destroy(&q);
}

int main() {
printf("beginning tests...\n");

Expand All @@ -760,7 +782,7 @@ int main() {
test_run(fragmenting_barrage_test, 20);
test_run(multithreaded_barrage_test, 20);
test_run(break_request_cleared_on_timeout);

test_run(sibling_test);
printf("done!\n");
return test_failure;
}

0 comments on commit 0a84f94

Please sign in to comment.