]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/str/test/run-strndup.c
tal/str: always create strings which have tal_count() == strlen() + 1.
[ccan] / ccan / tal / str / test / run-strndup.c
index 55e35fd4be8c6fb1a8033a311d1ff4d8c17ff001..94689d8c6d7aa6fd52496a192a217a2a32d593c1 100644 (file)
@@ -9,12 +9,13 @@ int main(void)
 {
        char *str, *copy;
 
 {
        char *str, *copy;
 
-       plan_tests(1);
+       plan_tests(2);
        str = malloc(5);
        memcpy(str, "hello", 5);
        /* We should be fine to strndup src without nul terminator. */
        copy = tal_strndup(NULL, str, 5);
        ok1(!strcmp(copy, "hello"));
        str = malloc(5);
        memcpy(str, "hello", 5);
        /* We should be fine to strndup src without nul terminator. */
        copy = tal_strndup(NULL, str, 5);
        ok1(!strcmp(copy, "hello"));
+       ok1(tal_count(copy) == strlen(copy) + 1);
        tal_free(copy);
        free(str);
 
        tal_free(copy);
        free(str);