tal: tal_dup()
[ccan] / ccan / tal / test / run-take.c
index dbc78a33b83a1d3a9ffcd654e3a2400851c87f91..53c1a44a85390e419075268efb157617390be71d 100644 (file)
@@ -6,7 +6,7 @@ int main(void)
 {
        char *parent, *c;
 
-       plan_tests(13);
+       plan_tests(15);
 
        parent = tal(NULL, char);
        ok1(parent);
@@ -25,10 +25,15 @@ int main(void)
        ok1(strcmp(c, "hel") == 0);
        ok1(tal_parent(c) == parent);
 
-       c = tal_memdup(TAL_TAKE, c, 1);
+       c = tal_dup(TAL_TAKE, char, c, 1, 0);
        ok1(c[0] == 'h');
        ok1(tal_parent(c) == parent);
 
+       c = tal_dup(TAL_TAKE, char, c, 1, 2);
+       ok1(c[0] == 'h');
+       strcpy(c, "hi");
+       ok1(tal_parent(c) == parent);
+
        /* No leftover allocations. */
        tal_free(c);
        ok1(tal_first(parent) == NULL);