Add emptiness checking to ql module
This commit is contained in:
parent
1dd24ca6d2
commit
a62b7ed928
@ -18,6 +18,8 @@ struct { \
|
|||||||
(a_head)->qlh_first = NULL; \
|
(a_head)->qlh_first = NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define ql_empty(a_head) ((a_head)->qlh_first == NULL)
|
||||||
|
|
||||||
#define ql_elm_new(a_elm, a_field) qr_new((a_elm), a_field)
|
#define ql_elm_new(a_elm, a_field) qr_new((a_elm), a_field)
|
||||||
|
|
||||||
#define ql_first(a_head) ((a_head)->qlh_first)
|
#define ql_first(a_head) ((a_head)->qlh_first)
|
||||||
|
@ -18,6 +18,7 @@ test_empty_list(list_head_t *head) {
|
|||||||
list_t *t;
|
list_t *t;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
expect_true(ql_empty(head), "Unexpected element for empty list");
|
||||||
expect_ptr_null(ql_first(head), "Unexpected element for empty list");
|
expect_ptr_null(ql_first(head), "Unexpected element for empty list");
|
||||||
expect_ptr_null(ql_last(head, link),
|
expect_ptr_null(ql_last(head, link),
|
||||||
"Unexpected element for empty list");
|
"Unexpected element for empty list");
|
||||||
@ -58,6 +59,7 @@ test_entries_list(list_head_t *head, list_t *entries, unsigned nentries) {
|
|||||||
list_t *t;
|
list_t *t;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
expect_false(ql_empty(head), "List should not be empty");
|
||||||
expect_c_eq(ql_first(head)->id, entries[0].id, "Element id mismatch");
|
expect_c_eq(ql_first(head)->id, entries[0].id, "Element id mismatch");
|
||||||
expect_c_eq(ql_last(head, link)->id, entries[nentries-1].id,
|
expect_c_eq(ql_last(head, link)->id, entries[nentries-1].id,
|
||||||
"Element id mismatch");
|
"Element id mismatch");
|
||||||
|
Loading…
Reference in New Issue
Block a user