First commit, fixed appending, create, destroy and get, all working fine

This commit is contained in:
2026-02-12 10:47:46 -06:00
commit 7611096e13
6 changed files with 293 additions and 0 deletions

32
tests/test_linkedlist.c Normal file
View File

@@ -0,0 +1,32 @@
#include "linkedlist.h"
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
static void linkedlist_test_append(void **state) {
(void) state;
LinkedList *ll;
linkedlist_create(&ll, sizeof(int));
for (int i = 10; i < 13; i++) {
linkedlist_append(ll, &i);
}
for (int i = 0; i < 3; i++) {
int n;
linkedlist_get(ll, i, &n);
assert_int_equal(n, i + 10);
}
linkedlist_destroy(ll);
}
int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(linkedlist_test_append),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}