diff options
| author | William Casarin <jb55@jb55.com> | 2018-07-09 15:48:55 -0700 |
|---|---|---|
| committer | William Casarin <jb55@jb55.com> | 2018-07-09 15:49:33 -0700 |
| commit | 0206052b5660cb77cdd0a0ac3c83dd4c3d996007 (patch) | |
| tree | f0b0f1cd48f0f8f67d85e981be114e84d36ac8b3 /ccan/tal/str/test/run-strndup.c | |
| parent | c999204365695799c9b7d79f4973d307421afecb (diff) | |
started on positioning + command structure
Diffstat (limited to 'ccan/tal/str/test/run-strndup.c')
| -rw-r--r-- | ccan/tal/str/test/run-strndup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ccan/tal/str/test/run-strndup.c b/ccan/tal/str/test/run-strndup.c new file mode 100644 index 0000000..55e35fd --- /dev/null +++ b/ccan/tal/str/test/run-strndup.c @@ -0,0 +1,22 @@ +#include <ccan/tal/str/str.h> +#include <stdlib.h> +#include <stdio.h> +#include <ccan/tal/str/str.c> +#include <ccan/tap/tap.h> +#include "helper.h" + +int main(void) +{ + 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(); +} |
