+
+ GNUNET_CONTAINER_heap_destroy (myHeap);
+
+ // My additions to a complete testcase
+ // Testing a GNUNET_CONTAINER_HEAP_ORDER_MIN
+ // Testing remove_node
+
+ myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+
+ 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)));
+
+ 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 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)));
+
+ 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
+ n4 = GNUNET_CONTAINER_heap_insert (myHeap, "40", 40);
+ n5 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
+ n6 = GNUNET_CONTAINER_heap_insert (myHeap, "60", 60);
+
+ // Inserting nodes deeper in the tree with lower costs
+ 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)));
+
+ // 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)));
+
+ // 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_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)));
+
+ // End Testing remove_node
+
+ // Testing a GNUNET_CONTAINER_HEAP_ORDER_MAX
+ GNUNET_CONTAINER_heap_destroy (myHeap);
+
+ myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX);
+
+ 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)));
+
+ 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 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)));
+
+ n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
+ n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
+ n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
+ n4 = GNUNET_CONTAINER_heap_insert (myHeap, "40", 40);
+ n5 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
+ n6 = GNUNET_CONTAINER_heap_insert (myHeap, "60", 60);
+
+ // Inserting nodes deeper in the tree with lower costs
+ 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)));
+
+ // 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)));
+
+ // 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_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)));
+
+ // End Testing remove_node
+