]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/str/test/run.c
tal/str: use tal_ prefix.
[ccan] / ccan / tal / str / test / run.c
index 303a0fd273e14e445ffb1f4406d9c89edbaa5f06..cb7cc199647397f4c5c74fa1174f003976fce84d 100644 (file)
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
        void *ctx;
 
        plan_tests(69);
-       split = strsplit(NULL, "hello  world", " ", STR_EMPTY_OK);
+       split = tal_strsplit(NULL, "hello  world", " ", STR_EMPTY_OK);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], ""));
        ok1(!strcmp(split[2], "world"));
@@ -23,21 +23,21 @@ int main(int argc, char *argv[])
        ok1(tal_count(split) == 4);
        tal_free(split);
 
-       split = strsplit(NULL, "hello  world", " ", STR_NO_EMPTY);
+       split = tal_strsplit(NULL, "hello  world", " ", STR_NO_EMPTY);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], "world"));
        ok1(split[2] == NULL);
        ok1(tal_count(split) == 3);
        tal_free(split);
 
-       split = strsplit(NULL, "  hello  world", " ", STR_NO_EMPTY);
+       split = tal_strsplit(NULL, "  hello  world", " ", STR_NO_EMPTY);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], "world"));
        ok1(split[2] == NULL);
        ok1(tal_count(split) == 3);
        tal_free(split);
 
-       split = strsplit(NULL, "hello  world", "o ", STR_EMPTY_OK);
+       split = tal_strsplit(NULL, "hello  world", "o ", STR_EMPTY_OK);
        ok1(!strcmp(split[0], "hell"));
        ok1(!strcmp(split[1], ""));
        ok1(!strcmp(split[2], ""));
@@ -47,36 +47,36 @@ int main(int argc, char *argv[])
        ok1(tal_count(split) == 6);
 
        ctx = split;
-       split = strsplit(ctx, "hello  world", "o ", STR_EMPTY_OK);
+       split = tal_strsplit(ctx, "hello  world", "o ", STR_EMPTY_OK);
        ok1(tal_parent(split) == ctx);
        tal_free(ctx);
 
-       str = strjoin(NULL, (char **)substrings, ", ", STR_TRAIL);
+       str = tal_strjoin(NULL, (char **)substrings, ", ", STR_TRAIL);
        ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar, "));
        ctx = str;
-       str = strjoin(ctx, (char **)substrings, "", STR_TRAIL);
+       str = tal_strjoin(ctx, (char **)substrings, "", STR_TRAIL);
        ok1(!strcmp(str, "farbarbazbbazar"));
        ok1(tal_parent(str) == ctx);
-       str = strjoin(ctx, (char **)substrings, ", ", STR_NO_TRAIL);
+       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 = strjoin(ctx, (char **)substrings, "", STR_NO_TRAIL);
+       str = tal_strjoin(ctx, (char **)substrings, "", STR_NO_TRAIL);
        ok1(!strcmp(str, "farbarbazbbazar"));
        ok1(tal_parent(str) == ctx);
        tal_free(ctx);
 
        ctx = tal_strdup(NULL, "context");
        /* Pass through NULLs from take. */
-       ok1(strsplit(NULL, take(NULL), " ", STR_EMPTY_OK) == NULL);
-       ok1(strsplit(NULL, "foo", take(NULL), STR_EMPTY_OK) == NULL);
+       ok1(tal_strsplit(NULL, take(NULL), " ", STR_EMPTY_OK) == NULL);
+       ok1(tal_strsplit(NULL, "foo", take(NULL), STR_EMPTY_OK) == NULL);
 
-       /* strsplit take string.  It reallocs it to same size, but
+       /* tal_strsplit take string.  It reallocs it to same size, but
         * that sometimes causes a move, so we can't directly check
         * that split[0] == str. */
        str = tal_strdup(ctx, "hello world");
        ok1(tal_check(ctx, NULL));
        ok1(tal_check(str, NULL));
-       split = strsplit(ctx, take(str), " ", STR_EMPTY_OK);
+       split = tal_strsplit(ctx, take(str), " ", STR_EMPTY_OK);
        ok1(tal_parent(split) == ctx);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], "world"));
@@ -87,9 +87,9 @@ int main(int argc, char *argv[])
        /* Previous free should get rid of str */
        ok1(!tal_first(ctx));
 
-       /* strsplit take delims */
+       /* tal_strsplit take delims */
        str = tal_strdup(ctx, " ");
-       split = strsplit(ctx, "hello world", take(str), STR_EMPTY_OK);
+       split = tal_strsplit(ctx, "hello world", take(str), STR_EMPTY_OK);
        ok1(tal_parent(split) == ctx);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], "world"));
@@ -100,9 +100,9 @@ int main(int argc, char *argv[])
        /* str is gone... */
        ok1(!tal_first(ctx));
 
-       /* strsplit takes both. */
-       split = strsplit(ctx, take(tal_strdup(NULL, "hello world")),
-                        take(tal_strdup(NULL, " ")), STR_EMPTY_OK);
+       /* tal_strsplit takes both. */
+       split = tal_strsplit(ctx, take(tal_strdup(NULL, "hello world")),
+                            take(tal_strdup(NULL, " ")), STR_EMPTY_OK);
        ok1(tal_parent(split) == ctx);
        ok1(!strcmp(split[0], "hello"));
        ok1(!strcmp(split[1], "world"));
@@ -113,15 +113,15 @@ int main(int argc, char *argv[])
        /* temp allocs are gone... */
        ok1(!tal_first(ctx));
 
-       /* strjoin passthrough taken NULLs OK. */
-       ok1(strjoin(ctx, take(NULL), "", STR_TRAIL) == NULL);
-       ok1(strjoin(ctx, take(NULL), "", STR_NO_TRAIL) == NULL);
-       ok1(strjoin(ctx, split, take(NULL), STR_TRAIL) == NULL);
-       ok1(strjoin(ctx, split, take(NULL), STR_NO_TRAIL) == NULL);
+       /* tal_strjoin passthrough taken NULLs OK. */
+       ok1(tal_strjoin(ctx, take(NULL), "", STR_TRAIL) == NULL);
+       ok1(tal_strjoin(ctx, take(NULL), "", STR_NO_TRAIL) == NULL);
+       ok1(tal_strjoin(ctx, split, take(NULL), STR_TRAIL) == NULL);
+       ok1(tal_strjoin(ctx, split, take(NULL), STR_NO_TRAIL) == NULL);
 
-       /* strjoin take strings[] */
-       split = strsplit(ctx, "hello world", " ", STR_EMPTY_OK);
-       str = strjoin(ctx, take(split), " there ", STR_NO_TRAIL);
+       /* tal_strjoin take strings[] */
+       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... */
@@ -129,10 +129,10 @@ int main(int argc, char *argv[])
        tal_free(str);
        ok1(!tal_first(ctx));
 
-       /* strjoin take delim */
-       split = strsplit(ctx, "hello world", " ", STR_EMPTY_OK);
-       str = strjoin(ctx, split, take(tal_strdup(ctx, " there ")),
-                     STR_NO_TRAIL);
+       /* tal_strjoin take delim */
+       split = tal_strsplit(ctx, "hello world", " ", STR_EMPTY_OK);
+       str = tal_strjoin(ctx, split, take(tal_strdup(ctx, " there ")),
+                         STR_NO_TRAIL);
        ok1(!strcmp(str, "hello there world"));
        ok1(tal_parent(str) == ctx);
        tal_free(split);
@@ -141,10 +141,10 @@ int main(int argc, char *argv[])
        tal_free(str);
        ok1(!tal_first(ctx));
 
-       /* strjoin take both. */
-       str = strjoin(ctx, take(strsplit(ctx, "hello world", " ",
-                                          STR_EMPTY_OK)),
-                     take(tal_strdup(ctx, " there ")), STR_NO_TRAIL);
+       /* tal_strjoin take both. */
+       str = tal_strjoin(ctx, take(tal_strsplit(ctx, "hello 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. */