2 This file is part of GNUnet.
3 Copyright (C) 2017 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @author Christian Grothoff
18 * @file util/test_container_dll.c
19 * @brief Test of DLL operations
23 #include "gnunet_util_lib.h"
31 * Required pointer to previous element.
36 * Required pointer to next element.
48 * Compare two elements.
50 * @param cls closure, NULL
51 * @param e1 an element of to sort
52 * @param e2 another element to sort
53 * @return #GNUNET_YES if @e1 < @e2, otherwise #GNUNET_NO
60 if (e1->value == e2->value)
62 return (e1->value < e2->value) ? 1 : -1;
67 main (int argc, char **argv)
69 unsigned int values[] = {
70 4, 5, 8, 6, 9, 3, 7, 2, 1, 0
72 struct Element *head = NULL;
73 struct Element *tail = NULL;
77 GNUNET_log_setup ("test-container-dll",
80 for (unsigned int off=0;
84 e = GNUNET_new (struct Element);
85 e->value = values[off];
86 GNUNET_CONTAINER_DLL_insert_sorted (struct Element,
95 while (NULL != (e = head))
97 GNUNET_assert (e->value == want);
98 GNUNET_CONTAINER_DLL_remove (head,
107 /* end of test_container_heap.c */