X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Ftest%2Frun-take.c;h=72d2e8e3cabd2878377a4a03fbbef960777dd2eb;hb=4814c4c79cc00ba61f865075af9ca8f919f6f370;hp=9f0a22c6c4ea24bf6cae5b0701564573b7bdb347;hpb=bb480e553f9d204b85a2e42de0be42c7b80eebda;p=ccan diff --git a/ccan/tal/test/run-take.c b/ccan/tal/test/run-take.c index 9f0a22c6..72d2e8e3 100644 --- a/ccan/tal/test/run-take.c +++ b/ccan/tal/test/run-take.c @@ -6,7 +6,7 @@ int main(void) { char *parent, *c; - plan_tests(32); + plan_tests(21); /* We can take NULL. */ ok1(take(NULL) == NULL); @@ -24,20 +24,8 @@ int main(void) ok1(!is_taken(parent)); ok1(!taken(parent)); - c = tal_strdup(parent, "hello"); - - c = tal_strdup(parent, take(c)); - ok1(strcmp(c, "hello") == 0); - ok1(tal_parent(c) == parent); - - c = tal_strndup(parent, take(c), 5); - ok1(strcmp(c, "hello") == 0); - ok1(tal_parent(c) == parent); - - c = tal_strndup(parent, take(c), 3); - ok1(strcmp(c, "hel") == 0); - ok1(tal_parent(c) == parent); - + c = tal(parent, char); + *c = 'h'; c = tal_dup(parent, char, take(c), 1, 0); ok1(c[0] == 'h'); ok1(tal_parent(c) == parent); @@ -56,23 +44,13 @@ int main(void) tal_free(c); ok1(tal_first(parent) == NULL); - c = tal_strdup(parent, "hello %s"); - c = tal_asprintf(parent, take(c), "there"); - ok1(strcmp(c, "hello there") == 0); - ok1(tal_parent(c) == parent); - /* No leftover allocations. */ - tal_free(c); - ok1(tal_first(parent) == NULL); - tal_free(parent); ok1(!taken_any()); /* NULL pass-through. */ c = NULL; - ok1(tal_strdup(NULL, take(c)) == NULL); - ok1(tal_strndup(NULL, take(c), 5) == NULL); ok1(tal_dup(NULL, char, take(c), 5, 5) == NULL); - ok1(tal_asprintf(NULL, take(c), 0) == NULL); + ok1(!taken_any()); return exit_status(); }