From d86d3fee70705ba700695c95f018eda084838bf5 Mon Sep 17 00:00:00 2001 From: Blake Romero Date: Fri, 10 Oct 2025 17:46:14 +0100 Subject: Rename & update list tests --- test/test_list.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/test_list.c (limited to 'test') diff --git a/test/test_list.c b/test/test_list.c new file mode 100644 index 0000000..d5d5123 --- /dev/null +++ b/test/test_list.c @@ -0,0 +1,57 @@ +#include +#include "../src/lib/list.h" + +Node* head = NULL; + +// Run on every test +void setup() { + head = node_init(7); +} + +// Run after every test +void teardown() { + list_free(&head); +} + +// Configure test suite +TestSuite(list, .init=setup, .fini=teardown); + +// Node +Test(list,init) { + int val = 17; + head = node_init(val); + cr_expect(head != NULL); + cr_expect(head->value == val); +} + +// Length +Test(list,length) { + cr_expect(list_length(head) == 1); +} + +// Push +Test(list,push) { + int val = 12; + list_push(&head,val); + cr_expect(head->next != NULL); + cr_expect(head->value == val); +} + +// Pop +Test(list,pop) { + int val = list_pop(&head); + cr_expect(val == 7); + cr_expect(list_length(head) == 0); +} + +// Append +// ... + +// Insert +// ... + +// Remove +// ... + +// Free +// ... -- cgit