1 #include "str_talloc/str_talloc.h"
4 #include "str_talloc/str_talloc.c"
8 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
10 int main(int argc, char *argv[])
15 split = strsplit(NULL, "hello world", " ", &n);
17 ok1(streq(split[0], "hello"));
18 ok1(streq(split[1], ""));
19 ok1(streq(split[2], "world"));
20 ok1(split[3] == NULL);
23 split = strsplit(NULL, "hello world", " ", NULL);
24 ok1(streq(split[0], "hello"));
25 ok1(streq(split[1], ""));
26 ok1(streq(split[2], "world"));
27 ok1(split[3] == NULL);
30 split = strsplit(NULL, "hello world", "o ", NULL);
31 ok1(streq(split[0], "hell"));
32 ok1(streq(split[1], ""));
33 ok1(streq(split[2], ""));
34 ok1(streq(split[3], "w"));
35 ok1(streq(split[4], "rld"));
36 ok1(split[5] == NULL);
39 split = strsplit(ctx, "hello world", "o ", NULL);
40 ok1(talloc_parent(split) == ctx);
43 str = strjoin(NULL, substrings, ", ");
44 ok1(streq(str, "far, bar, baz, b, ba, z, ar, "));
46 str = strjoin(ctx, substrings, "");
47 ok1(streq(str, "farbarbazbbazar"));
48 ok1(talloc_parent(str) == ctx);