1 #include <ccan/tal/tal.h>
2 #include <ccan/tal/tal.c>
3 #include <ccan/tap/tap.h>
11 parent = tal(NULL, char);
14 c = tal_strdup(parent, "hello");
15 ok1(strcmp(c, "hello") == 0);
16 ok1(tal_parent(c) == parent);
18 c = tal_strndup(parent, "hello", 3);
19 ok1(strcmp(c, "hel") == 0);
20 ok1(tal_parent(c) == parent);
22 c = tal_typechk_(parent, char *);
23 c = tal_dup(parent, char, "hello", 6, 0);
24 ok1(strcmp(c, "hello") == 0);
25 ok1(strcmp(tal_name(c), "char[]") == 0);
26 ok1(tal_parent(c) == parent);
28 /* Now with an extra byte. */
29 c = tal_dup(parent, char, "hello", 6, 1);
30 ok1(strcmp(c, "hello") == 0);
31 ok1(strcmp(tal_name(c), "char[]") == 0);
32 ok1(tal_parent(c) == parent);
35 c = tal_asprintf(parent, "hello %s", "there");
36 ok1(strcmp(c, "hello there") == 0);
37 ok1(tal_parent(c) == parent);