First commit, fixed appending, create, destroy and get, all working fine
This commit is contained in:
32
tests/test_linkedlist.c
Normal file
32
tests/test_linkedlist.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user