tal: add typenames by default.
[ccan] / ccan / tal / test / run-named-debug.c
1 #define CCAN_TAL_DEBUG
2 #include <ccan/tal/tal.h>
3 #include <ccan/tal/tal.c>
4 #include <ccan/tap/tap.h>
5
6 int main(void)
7 {
8         int *p;
9         char name[] = "test name";
10
11         plan_tests(6);
12
13         p = tal(NULL, int);
14         ok1(strcmp(tal_name(p), __FILE__ ":13:int") == 0);
15
16         tal_set_name(p, "some literal");
17         ok1(strcmp(tal_name(p), "some literal") == 0);
18
19         tal_set_name(p, name);
20         ok1(strcmp(tal_name(p), name) == 0);
21         /* You can't reuse my pointer though! */
22         ok1(tal_name(p) != name);
23
24         tal_set_name(p, "some other literal");
25         ok1(strcmp(tal_name(p), "some other literal") == 0);
26
27         tal_free(p);
28
29         p = tal_arr(NULL, int, 2);
30         ok1(strcmp(tal_name(p), __FILE__ ":29:int[]") == 0);
31         tal_free(p);
32
33         return exit_status();
34 }