Add test for HTAB_FOREACH_ELEM.
@@ -19,6 +19,11 @@ static void f (int i, void *arg) {
sum += i;
}
+static void add (int i, void *arg) {
+ int *sum = arg;
+ (*sum) += i;
+}
+
int main (void) {
int i, collisions, iter, tab_el;
HTAB (int) * htab;
@@ -32,6 +37,9 @@ int main (void) {
status &= HTAB_ELS_NUM (int, htab) == i + 1;
}
sum = 0;
+ HTAB_FOREACH_ELEM (int, htab, add, &sum);
+ status &= sum == 4950;
+ sum = 0;
HTAB_CLEAR (int, htab);
status &= sum == 4950;
status &= HTAB_ELS_NUM (int, htab) == 0;
