tal/str: always create strings which have tal_count() == strlen() + 1.
[ccan] / ccan / tal / str / test / run-fmt-terminate.c
1 #include <ccan/tal/str/str.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <ccan/tal/str/str.c>
5 #include <ccan/tap/tap.h>
6 #include "helper.h"
7
8 /* Empty format string: should still terminate! */
9 int main(void)
10 {
11         char *str;
12         const char *fmt = "";
13
14         plan_tests(2);
15         /* GCC complains about empty format string, complains about non-literal
16          * with no args... */
17         str = tal_fmt(NULL, fmt, "");
18         ok1(!strcmp(str, ""));
19         ok1(tal_count(str) == strlen(str) + 1);
20         tal_free(str);
21
22         return exit_status();
23 }