test_list.c
Test suite for libft’s singly-linked list (t_list).
Storage convention: ft_lstnew(ptr) stores the pointer directly in content. Access pattern: (T *)node->content — wrapped here by the LST_DUMMY() macro.
- Author
pulgamecanica (arosado-)
Covers ft_lstnew(), ft_lstsize(), forward traversal, ft_lstdel() (pointer-and-node free), and ft_lstadd() (prepend to front).
This suite is always compiled and always runs — it is not guarded by a feature flag because t_list is a core Libft primitive.
Defines
-
LST_DUMMY(n)
Functions
-
static void del_dummy(void *content)
-
static void lst_append(t_list **head, t_list *node)
-
void test_list_suite(void)
Run all singly-linked list assertions.
Builds an append-order list
[alpha(1) -> beta(2) -> gamma(3)], verifies ft_lstsize() and forward traversal via->next, then exercises ft_lstdel() (freeing all nodes with del_dummy) and asserts the head pointer is NULL afterwards.A second sub-test uses ft_lstadd() (prepend) to verify that two nodes inserted as
[first, second]are stored as[second -> first]in the list.Precondition:
Libft/srcs/ft_stdlib/must be compiled and linked.
-
struct t_dummy