split = tal_strsplit(NULL, "hello world", " ", STR_EMPTY_OK);
ok1(!strcmp(split[0], "hello"));
ok1(!strcmp(split[1], ""));
split = tal_strsplit(NULL, "hello world", " ", STR_EMPTY_OK);
ok1(!strcmp(split[0], "hello"));
ok1(!strcmp(split[1], ""));
str = tal_strjoin(NULL, (char **)substrings, ", ", STR_TRAIL);
ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar, "));
str = tal_strjoin(NULL, (char **)substrings, ", ", STR_TRAIL);
ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar, "));
ctx = str;
str = tal_strjoin(ctx, (char **)substrings, "", STR_TRAIL);
ok1(!strcmp(str, "farbarbazbbazar"));
ctx = str;
str = tal_strjoin(ctx, (char **)substrings, "", STR_TRAIL);
ok1(!strcmp(str, "farbarbazbbazar"));
ok1(tal_parent(str) == ctx);
str = tal_strjoin(ctx, (char **)substrings, ", ", STR_NO_TRAIL);
ok1(tal_parent(str) == ctx);
ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar"));
ok1(tal_parent(str) == ctx);
str = tal_strjoin(ctx, (char **)substrings, ", ", STR_NO_TRAIL);
ok1(tal_parent(str) == ctx);
ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar"));
str = tal_strjoin(ctx, (char **)substrings, "", STR_NO_TRAIL);
ok1(!strcmp(str, "farbarbazbbazar"));
ok1(tal_parent(str) == ctx);
str = tal_strjoin(ctx, (char **)substrings, "", STR_NO_TRAIL);
ok1(!strcmp(str, "farbarbazbbazar"));
ok1(tal_parent(str) == ctx);
str = tal_strdup(ctx, "hello world");
ok1(tal_check(ctx, NULL));
ok1(tal_check(str, NULL));
str = tal_strdup(ctx, "hello world");
ok1(tal_check(ctx, NULL));
ok1(tal_check(str, NULL));
split = tal_strsplit(ctx, take(str), " ", STR_EMPTY_OK);
ok1(tal_parent(split) == ctx);
ok1(!strcmp(split[0], "hello"));
split = tal_strsplit(ctx, take(str), " ", STR_EMPTY_OK);
ok1(tal_parent(split) == ctx);
ok1(!strcmp(split[0], "hello"));
/* tal_strsplit take delims */
str = tal_strdup(ctx, " ");
/* tal_strsplit take delims */
str = tal_strdup(ctx, " ");
split = tal_strsplit(ctx, "hello world", take(str), STR_EMPTY_OK);
ok1(tal_parent(split) == ctx);
ok1(!strcmp(split[0], "hello"));
split = tal_strsplit(ctx, "hello world", take(str), STR_EMPTY_OK);
ok1(tal_parent(split) == ctx);
ok1(!strcmp(split[0], "hello"));
split = tal_strsplit(ctx, "hello world", " ", STR_EMPTY_OK);
str = tal_strjoin(ctx, take(split), " there ", STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
split = tal_strsplit(ctx, "hello world", " ", STR_EMPTY_OK);
str = tal_strjoin(ctx, take(split), " there ", STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
ok1(tal_parent(str) == ctx);
/* split is gone... */
ok1(single_child(ctx, str));
ok1(tal_parent(str) == ctx);
/* split is gone... */
ok1(single_child(ctx, str));
STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
ok1(tal_parent(str) == ctx);
STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
ok1(tal_parent(str) == ctx);
tal_free(split);
/* tmp alloc is gone, str is only remainder. */
ok1(single_child(ctx, str));
tal_free(split);
/* tmp alloc is gone, str is only remainder. */
ok1(single_child(ctx, str));
STR_EMPTY_OK)),
take(tal_strdup(ctx, " there ")), STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
STR_EMPTY_OK)),
take(tal_strdup(ctx, " there ")), STR_NO_TRAIL);
ok1(!strcmp(str, "hello there world"));
ok1(tal_parent(str) == ctx);
/* tmp allocs are gone, str is only remainder. */
ok1(single_child(ctx, str));
ok1(tal_parent(str) == ctx);
/* tmp allocs are gone, str is only remainder. */
ok1(single_child(ctx, str));