1 #include "str_talloc/str_talloc.h"
4 #include "str_talloc/str_talloc.c"
9 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
11 static char *substrings[] = { "far", "bar", "baz", "b", "ba", "z", "ar", NULL };
13 int main(int argc, char *argv[])
20 split = strsplit(NULL, "hello world", " ", &n);
22 ok1(streq(split[0], "hello"));
23 ok1(streq(split[1], ""));
24 ok1(streq(split[2], "world"));
25 ok1(split[3] == NULL);
28 split = strsplit(NULL, "hello world", " ", NULL);
29 ok1(streq(split[0], "hello"));
30 ok1(streq(split[1], ""));
31 ok1(streq(split[2], "world"));
32 ok1(split[3] == NULL);
35 split = strsplit(NULL, "hello world", "o ", NULL);
36 ok1(streq(split[0], "hell"));
37 ok1(streq(split[1], ""));
38 ok1(streq(split[2], ""));
39 ok1(streq(split[3], "w"));
40 ok1(streq(split[4], "rld"));
41 ok1(split[5] == NULL);
44 split = strsplit(ctx, "hello world", "o ", NULL);
45 ok1(talloc_parent(split) == ctx);
48 str = strjoin(NULL, substrings, ", ");
49 ok1(streq(str, "far, bar, baz, b, ba, z, ar, "));
51 str = strjoin(ctx, substrings, "");
52 ok1(streq(str, "farbarbazbbazar"));
53 ok1(talloc_parent(str) == ctx);