From 1fd84c7dc70a0a6e6d8651fafa50c51dd697ae77 Mon Sep 17 00:00:00 2001 From: Benedict Date: Thu, 2 Feb 2017 00:32:26 +0100 Subject: added random stuff which hasn't beend added because yeah --- lib/test_list.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/test_list.c (limited to 'lib/test_list.c') 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 +#include + + +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); + } + +} -- cgit v1.2.3-70-g09d2