diff options
Diffstat (limited to 'src/test/check_list.c')
-rw-r--r-- | src/test/check_list.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/test/check_list.c b/src/test/check_list.c index 8677cd3..fe23b2b 100644 --- a/src/test/check_list.c +++ b/src/test/check_list.c @@ -2,7 +2,7 @@ #include <stdlib.h> #include "../list.h" -void +static void print_int(void *p) { printf("%d\n", *((int *)p)); @@ -155,6 +155,8 @@ main(U_ATTR int argc, U_ATTR char **argv) exit(1); } + eprintf("Successfully created LS2!\n"); + for (NUM i = 0; i < 5; i++) { int *pointer = malloc(sizeof *pointer * 1); @@ -197,7 +199,7 @@ main(U_ATTR int argc, U_ATTR char **argv) } NUM arr[10]; - + for (NUM i = 0; i < 10; i++) { arr[i] = i*i-i+1; if (add_to_list(ls, arr+i)) { @@ -211,7 +213,28 @@ main(U_ATTR int argc, U_ATTR char **argv) destroy_list(ls, 0); + /* test array_to_list */ + int *arr3 = MYALLOC(int, 20); + + void **arr2 = NULL; + + for (NUM i = 0; i < 20; i++) { + *(arr3+i) = i*i+i+1; + } + + arr2 = MYALLOC(void *, 20); + + for (NUM i = 0; i < 20; i++) *(arr2+i) = arr3+i; + + ls = array_to_list(arr2, 20); + + printf("Printing a list from an array\n"); + + map_list(ls, print_int); + + destroy_list(ls, 2); + printf("Every test is successful!\n"); - + return 0; } |