tal: add tal_count() and length properties for arrays.
[ccan] / ccan / tal / test / run-count.c
1 #include <ccan/tal/tal.h>
2 #include <ccan/tal/tal.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         char *p1, *p2;
8
9         plan_tests(12);
10
11         p1 = tal(NULL, char);
12         ok1(p1);
13         ok1(tal_count(p1) == 0);
14
15         p2 = tal_arr(p1, char, 1);
16         ok1(p2);
17         ok1(tal_count(p2) == 1);
18         ok1(tal_resize(&p2, 2));
19         ok1(tal_count(p2) == 2);
20         ok1(tal_check(NULL, NULL));
21         tal_free(p2);
22
23         p2 = tal_arrz(p1, char, 7);
24         ok1(p2);
25         ok1(tal_count(p2) == 7);
26         ok1(tal_resize(&p2, 0));
27         ok1(tal_count(p2) == 0);
28         ok1(tal_check(NULL, NULL));
29         tal_free(p2);
30         tal_free(p1);
31
32         return exit_status();
33 }