GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
return GNUNET_OK;
}
+static int
+nstrcmp (const char *a,
+ const char *b)
+{
+ GNUNET_assert (a != NULL);
+ GNUNET_assert (b != NULL);
+ return strcmp (a,b);
+}
+
static int
check ()
{
struct GNUNET_CONTAINER_HeapNode *n6;
struct GNUNET_CONTAINER_HeapNode *n7;
struct GNUNET_CONTAINER_HeapNode *n8;
+ const char *r;
myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
n6 = GNUNET_CONTAINER_heap_insert (myHeap, "30/200", 30);
GNUNET_assert (5 == GNUNET_CONTAINER_heap_get_size (myHeap));
GNUNET_CONTAINER_heap_remove_node (myHeap, n5);
+ r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n1 */
+ GNUNET_assert (NULL != r);
GNUNET_assert (0 == strcmp ("11",
- GNUNET_CONTAINER_heap_remove_root (myHeap))); /* n1 */
+ r));
GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200);
GNUNET_CONTAINER_heap_remove_node (myHeap, n3);
+ r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n4 */
+ GNUNET_assert (NULL != r);
GNUNET_assert (0 == strcmp ("50",
- GNUNET_CONTAINER_heap_remove_root (myHeap))); /* n4 */
- GNUNET_assert (0 == strcmp ("30/200",
- GNUNET_CONTAINER_heap_remove_root (myHeap))); /* n6 */
+ r));
+ r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n6 */
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("30/200", r));
GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (myHeap));
GNUNET_CONTAINER_heap_destroy (myHeap);
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("10", r));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
- GNUNET_assert (0 == strcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ r = GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("20", r));
+ r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("10", r));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
+ r = GNUNET_CONTAINER_heap_remove_root (myHeap);
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("30", r));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+ r = GNUNET_CONTAINER_heap_remove_node (myHeap, n3);
+ GNUNET_assert (NULL != r);
+ GNUNET_assert (0 == strcmp ("30", r));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
- GNUNET_assert (0 == strcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap)));
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
+ GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
+ GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap)));
+ GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+ GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
// Cleaning up...
- GNUNET_assert (0 == strcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));
- GNUNET_assert (0 == strcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
+ GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));
+ GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
// Testing heap_walk_get_next
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
- GNUNET_assert (0 == strcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
- GNUNET_assert (0 == strcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
- GNUNET_assert (0 == strcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));
- GNUNET_assert (0 == strcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
+ GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
+ GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
+ GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));
+ GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
// End Testing remove_node
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
- GNUNET_assert (0 == strcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
+ GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
+ GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+ GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);
- GNUNET_assert (0 == strcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+ GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
// Cleaning up...
- GNUNET_assert (0 == strcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));
- GNUNET_assert (0 == strcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
+ GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));
+ GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
// Testing heap_walk_get_next
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
GNUNET_CONTAINER_heap_walk_get_next (myHeap);
- GNUNET_assert (0 == strcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
- GNUNET_assert (0 == strcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
- GNUNET_assert (0 == strcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
- GNUNET_assert (0 == strcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));
- GNUNET_assert (0 == strcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
+ GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+ GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
+ GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
+ GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));
+ GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
// End Testing remove_node