Skip to content

Commit

Permalink
add a test for a LIST_INSERT_HEAD bug
Browse files Browse the repository at this point in the history
cf. #263
  • Loading branch information
yamt committed Sep 20, 2024
1 parent 954598b commit e9226fa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,18 @@ test_list(void **state)
assert_null(LIST_FIRST(&h));
assert_null(LIST_LAST(&h, struct item, entry));

memset(&item, 0, sizeof(item));
LIST_INSERT_HEAD(&h, &item, entry);
assert_false(LIST_EMPTY(&h));
assert_ptr_equal(LIST_FIRST(&h), &item);
assert_ptr_equal(LIST_LAST(&h, struct item, entry), &item);
assert_null(LIST_NEXT(&item, entry));
assert_null(LIST_PREV(&item, &h, struct item, entry));
LIST_REMOVE(&h, &item, entry);
assert_true(LIST_EMPTY(&h));
assert_null(LIST_FIRST(&h));
assert_null(LIST_LAST(&h, struct item, entry));

struct item items[10];
int i;
for (i = 0; i < 10; i++) {
Expand Down

0 comments on commit e9226fa

Please sign in to comment.