X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Fstr%2Ftest%2Frun-strndup.c;fp=ccan%2Ftal%2Fstr%2Ftest%2Frun-strndup.c;h=d967354842c2ef083543061612e5143ed7701c8a;hb=28681e0a15c453e86528ca488415e2220cbe0f0a;hp=0000000000000000000000000000000000000000;hpb=6e5c2f3f55d4e537ccc69703cc41a4295afcd170;p=ccan diff --git a/ccan/tal/str/test/run-strndup.c b/ccan/tal/str/test/run-strndup.c new file mode 100644 index 00000000..d9673548 --- /dev/null +++ b/ccan/tal/str/test/run-strndup.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include "helper.h" + +int main(int argc, char *argv[]) +{ + char *str, *copy; + + plan_tests(1); + 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")); + tal_free(copy); + free(str); + + return exit_status(); +}