tal: add typenames by default.
[ccan] / ccan / tal / test / run-named.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         int *p;
8         char name[] = "test name";
9
10         plan_tests(6);
11
12         p = tal(NULL, int);
13         ok1(strcmp(tal_name(p), "int") == 0);
14
15         tal_set_name(p, "some literal");
16         ok1(strcmp(tal_name(p), "some literal") == 0);
17
18         tal_set_name(p, name);
19         ok1(strcmp(tal_name(p), name) == 0);
20         /* You can't reuse my pointer though! */
21         ok1(tal_name(p) != name);
22
23         tal_set_name(p, "some other literal");
24         ok1(strcmp(tal_name(p), "some other literal") == 0);
25
26         tal_free(p);
27
28         p = tal_arr(NULL, int, 2);
29         ok1(strcmp(tal_name(p), "int[]") == 0);
30         tal_free(p);
31
32         return exit_status();
33 }