tally: fix FreeBSD compile, memleak in tests.
[ccan] / ccan / tally / test / run-min-max.c
1 #include <ccan/tally/tally.c>
2 #include <ccan/tap/tap.h>
3
4 int main(void)
5 {
6         int i;
7         struct tally *tally = tally_new(0);
8
9         plan_tests(100 * 4);
10         /* Test max, min and num. */
11         for (i = 0; i < 100; i++) {
12                 tally_add(tally, i);
13                 ok1(tally_num(tally) == i*2 + 1);
14                 tally_add(tally, -i);
15                 ok1(tally_num(tally) == i*2 + 2);
16                 ok1(tally_max(tally) == i);
17                 ok1(tally_min(tally) == -i);
18         }
19         free(tally);
20         return exit_status();
21 }