diff options
Diffstat (limited to 'lib/test_list.c')
| -rw-r--r-- | lib/test_list.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/test_list.c b/lib/test_list.c new file mode 100644 index 0000000..7e72fb8 --- /dev/null +++ b/lib/test_list.c @@ -0,0 +1,51 @@ +#include "doublelinkedlist.h" +#include <stdlib.h> +#include <stdio.h> + + +struct in { + int low; + int max; + struct list next; +}; + +int main() +{ + struct in tmp; + struct in tmp2; + struct in tmp3; + struct in tmp4; + struct list *iter, *head; + + tmp.low = 1; + tmp.max = 3; + tmp2.low = 5; + tmp2.max = 9; + tmp3.low = 14; + tmp3.max = 16; + tmp4.low = 23; + tmp4.max = 35; + + LIST_INIT(&tmp.next); + LIST_INIT(&tmp2.next); + LIST_INIT(&tmp3.next); + LIST_INIT(&tmp4.next); + + list_insert_after(&tmp.next, &tmp2.next); + list_insert_after(&tmp2.next, &tmp3.next); + list_insert_after(&tmp3.next, &tmp4.next); + + head = &tmp2.next; + + LIST_TO_END(iter, head) { + struct in *i = CONTAINER_OF(iter, struct in, next); + printf("low: %i, max: %i\n", i->low, i->max); + } + + list_delete(&tmp4.next); + LIST_TO_END(iter, head) { + struct in *i = CONTAINER_OF(iter, struct in, next); + printf("low: %i, max: %i\n", i->low, i->max); + } + +} |
