1 #include <ccan/stringbuilder/stringbuilder.h>
2 #include <ccan/stringbuilder/stringbuilder.c>
7 * This triggers a circular dependency
8 * #include <ccan/str/str.h>
10 * We only want the following macro:
12 #define streq(s1,s2) (!strcmp(s1,s2))
14 #include <ccan/tap/tap.h>
16 int main(int argc, char *argv[])
19 const char* str_array[] = {
24 res = stringbuilder(string, sizeof(string), NULL,
26 printf("res: %s, string: %s\n",
27 strerror(res), string);
29 ok1(streq(string, "aaabbb"));
31 res = stringbuilder(string, sizeof(string), NULL,
32 "aaaaa", "bbbbb", "ccccc", "ddddd",
34 printf("res: %s, string: %s\n",
35 strerror(res), string);
38 res = stringbuilder(string, sizeof(string), ", ",
40 printf("res: %s, string: %s\n",
41 strerror(res), string);
43 ok1(streq(string, "aaa"));
45 res = stringbuilder(string, sizeof(string), ", ",
47 printf("res: %s, string: %s\n",
48 strerror(res), string);
50 ok1(streq(string, "aaa, bbb"));
52 res = stringbuilder_array(string, sizeof(string), NULL,
53 sizeof(str_array)/sizeof(str_array[0]), str_array);
54 printf("res: %s, string: %s\n",
55 strerror(res), string);
57 ok1(streq(string, "xxxyyy"));
59 res = stringbuilder_array(string, sizeof(string), ", ",
60 sizeof(str_array)/sizeof(str_array[0]), str_array);
61 printf("res: %s, string: %s\n",
62 strerror(res), string);
64 ok1(streq(string, "xxx, yyy"));