aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-list.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-08-09 20:10:01 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-09 20:18:32 (GMT)
commitdcf10b4502bd7f07d0d5132b62112f3850c24fbb (patch)
treea96612fb3badad072aba2487ac1d5fcc90f5ec4e /tests/test-list.c
parent3aed10f3b7f643f288f6aa1c5aef223c5c679b9e (diff)
downloadhostap-aosp-jb.zip
hostap-aosp-jb.tar.gz
hostap-aosp-jb.tar.bz2
AOSP: These files have been removed from AOSPaosp-jb
Diffstat (limited to 'tests/test-list.c')
-rw-r--r--tests/test-list.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/tests/test-list.c b/tests/test-list.c
deleted file mode 100644
index 01bcbf6..0000000
--- a/tests/test-list.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Doubly-linked list - test program
- * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
- *
- * This software may be distributed under the terms of the BSD license.
- * See README for more details.
- */
-
-#include "utils/includes.h"
-#include "utils/os.h"
-#include "utils/list.h"
-
-struct test {
- struct dl_list list;
- int value;
-};
-
-static void dump_list(struct dl_list *head)
-{
- struct test *t;
- printf("dump:");
- dl_list_for_each(t, head, struct test, list)
- printf(" %d", t->value);
- printf(" (len=%d%s)\n", dl_list_len(head),
- dl_list_empty(head) ? " empty" : "");
-}
-
-int main(int argc, char *argv[])
-{
- struct dl_list head;
- struct test *t, *tmp;
- int i;
-
- dl_list_init(&head);
- dump_list(&head);
-
- for (i = 0; i < 5; i++) {
- t = os_zalloc(sizeof(*t));
- if (t == NULL)
- return -1;
- t->value = i;
- dl_list_add(&head, &t->list);
- dump_list(&head);
- }
-
- for (i = 10; i > 5; i--) {
- t = os_zalloc(sizeof(*t));
- if (t == NULL)
- return -1;
- t->value = i;
- dl_list_add_tail(&head, &t->list);
- dump_list(&head);
- }
-
- i = 0;
- dl_list_for_each(t, &head, struct test, list)
- if (++i == 5)
- break;
- printf("move: %d\n", t->value);
- dl_list_del(&t->list);
- dl_list_add(&head, &t->list);
- dump_list(&head);
-
- dl_list_for_each_safe(t, tmp, &head, struct test, list) {
- printf("delete: %d\n", t->value);
- dl_list_del(&t->list);
- os_free(t);
- dump_list(&head);
- }
-
- return 0;
-}