+/** @brief Less-than comparison function for integer heap */
+static inline int int_lt(int a, int b) { return a < b; }
+
+/** @struct iheap
+ * @brief A heap with @c int elements */
+HEAP_TYPE(iheap, int, int_lt);
+
+/** @brief Tests for @ref heap.h */
+static void test_heap(void) {
+ struct iheap h[1];
+ int n;
+ int last = -1;
+
+ fprintf(stderr, "test_heap\n");
+
+ iheap_init(h);
+ for(n = 0; n < 1000; ++n)
+ iheap_insert(h, random() % 100);
+ for(n = 0; n < 1000; ++n) {
+ const int latest = iheap_remove(h);
+ if(last > latest)
+ fprintf(stderr, "should have %d <= %d\n", last, latest);
+ insist(last <= latest);
+ last = latest;
+ }
+ putchar('\n');
+}
+