+/* Inserts elements into an HMAPX in ascending order, then clears the hash
+ table using hmapx_clear(). */
+static void
+test_clear (void)
+{
+ const int max_elems = 128;
+ struct element *elements;
+ struct hmapx_node **nodes;
+ int *values;
+ struct hmapx hmapx;
+ int cnt;
+
+ elements = xnmalloc (max_elems, sizeof *elements);
+ nodes = xnmalloc (max_elems, sizeof *nodes);
+ values = xnmalloc (max_elems, sizeof *values);
+
+ hmapx_init (&hmapx);
+ for (cnt = 0; cnt <= max_elems; cnt++)
+ {
+ int i;
+
+ for (i = 0; i < cnt; i++)
+ {
+ values[i] = elements[i].data = i;
+ nodes[i] = hmapx_insert (&hmapx, &elements[i],
+ random_hash (elements[i].data));
+ check_hmapx (&hmapx, values, i + 1, random_hash);
+ }
+ hmapx_clear (&hmapx);
+ check_hmapx (&hmapx, NULL, 0, random_hash);
+ }
+ hmapx_destroy (&hmapx);
+
+ free (elements);
+ free (nodes);
+ free (values);
+}
+