summaryrefslogtreecommitdiff
path: root/src/test/check_list.c
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-01-04 11:51:58 +0800
committerJSDurand <mmemmew@gmail.com>2022-01-04 11:51:58 +0800
commit55dc897da6e81f2a26cfc7e66ac942824773498b (patch)
treefce0d7d57832907c991d551833bf5eecde947dd2 /src/test/check_list.c
parent53b8b6ffab5a968db75e9babddf4e2dbb2c688a3 (diff)
temporary commit
Now we can read grammars from a file. But we need to check if it works for reading strings still.
Diffstat (limited to 'src/test/check_list.c')
-rw-r--r--src/test/check_list.c29
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;
}