]> git.ozlabs.org Git - ccan/blobdiff - ccan/str_talloc/test/run.c
antithread, foreach, grab_file, hashtable, str_talloc: fix _info depends.
[ccan] / ccan / str_talloc / test / run.c
index 6da48bd0bc98f2c5fceb776012e08c5c1372b8b1..c8cc6217bd6e5832d2d0cee2a703a80964567d2c 100644 (file)
@@ -1,38 +1,42 @@
-#include "str_talloc/str_talloc.h"
+#include <ccan/str_talloc/str_talloc.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "str_talloc/str_talloc.c"
-#include "tap/tap.h"
+#include <ccan/str_talloc/str_talloc.c>
+#include <ccan/tap/tap.h>
 
 /* FIXME: ccanize */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 
+static char *substrings[] = { "far", "bar", "baz", "b", "ba", "z", "ar", NULL };
+
 int main(int argc, char *argv[])
 {
-       unsigned int i, j, n;
+       unsigned int n;
+       char **split, *str;
+       void *ctx;
 
        plan_tests(19);
        split = strsplit(NULL, "hello  world", " ", &n);
        ok1(n == 3);
-       ok1(streq(split[0], "hello"));
-       ok1(streq(split[1], ""));
-       ok1(streq(split[2], "world"));
+       ok1(!strcmp(split[0], "hello"));
+       ok1(!strcmp(split[1], ""));
+       ok1(!strcmp(split[2], "world"));
        ok1(split[3] == NULL);
        talloc_free(split);
 
        split = strsplit(NULL, "hello  world", " ", NULL);
-       ok1(streq(split[0], "hello"));
-       ok1(streq(split[1], ""));
-       ok1(streq(split[2], "world"));
+       ok1(!strcmp(split[0], "hello"));
+       ok1(!strcmp(split[1], ""));
+       ok1(!strcmp(split[2], "world"));
        ok1(split[3] == NULL);
        talloc_free(split);
 
        split = strsplit(NULL, "hello  world", "o ", NULL);
-       ok1(streq(split[0], "hell"));
-       ok1(streq(split[1], ""));
-       ok1(streq(split[2], ""));
-       ok1(streq(split[3], "w"));
-       ok1(streq(split[4], "rld"));
+       ok1(!strcmp(split[0], "hell"));
+       ok1(!strcmp(split[1], ""));
+       ok1(!strcmp(split[2], ""));
+       ok1(!strcmp(split[3], "w"));
+       ok1(!strcmp(split[4], "rld"));
        ok1(split[5] == NULL);
 
        ctx = split;
@@ -41,10 +45,10 @@ int main(int argc, char *argv[])
        talloc_free(ctx);
 
        str = strjoin(NULL, substrings, ", ");
-       ok1(streq(str, "far, bar, baz, b, ba, z, ar, "));
+       ok1(!strcmp(str, "far, bar, baz, b, ba, z, ar, "));
        ctx = str;
        str = strjoin(ctx, substrings, "");
-       ok1(streq(str, "farbarbazbbazar"));
+       ok1(!strcmp(str, "farbarbazbbazar"));
        ok1(talloc_parent(str) == ctx);
        talloc_free(ctx);