1 #include <ccan/stringbuilder/stringbuilder.h>
2 #include <ccan/stringbuilder/stringbuilder.c>
3 #include <ccan/str/str.h>
8 #include <ccan/tap/tap.h>
10 int main(int argc, char *argv[])
13 const char* str_array[] = {
18 res = stringbuilder(string, sizeof(string), NULL,
20 printf("res: %s, string: %s\n",
21 strerror(res), string);
23 ok1(streq(string, "aaabbb"));
25 res = stringbuilder(string, sizeof(string), NULL,
26 "aaaaa", "bbbbb", "ccccc", "ddddd",
28 printf("res: %s, string: %s\n",
29 strerror(res), string);
32 res = stringbuilder(string, sizeof(string), ", ",
34 printf("res: %s, string: %s\n",
35 strerror(res), string);
37 ok1(streq(string, "aaa"));
39 res = stringbuilder(string, sizeof(string), ", ",
41 printf("res: %s, string: %s\n",
42 strerror(res), string);
44 ok1(streq(string, "aaa, bbb"));
46 res = stringbuilder_array(string, sizeof(string), NULL,
47 sizeof(str_array)/sizeof(str_array[0]), str_array);
48 printf("res: %s, string: %s\n",
49 strerror(res), string);
51 ok1(streq(string, "xxxyyy"));
53 res = stringbuilder_array(string, sizeof(string), ", ",
54 sizeof(str_array)/sizeof(str_array[0]), str_array);
55 printf("res: %s, string: %s\n",
56 strerror(res), string);
58 ok1(streq(string, "xxx, yyy"));