]> git.ozlabs.org Git - ccan/blobdiff - ccan/str/test/run.c
str: clean up tests so ccanlint doesn't complain about memory leaking.
[ccan] / ccan / str / test / run.c
index b55444a15b595f25250d9de4172187d9fbea675a..4648692be655165413d5cc250844df35f4553ccb 100644 (file)
@@ -1,7 +1,7 @@
-#include "str/str.h"
+#include <ccan/str/str.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "tap/tap.h"
+#include <ccan/tap/tap.h>
 
 /* FIXME: ccanize */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       plan_tests(n * n * 5);
+       plan_tests(n * n * 5 + 3);
        for (i = 0; i < n; i++) {
                for (j = 0; j < n; j++) {
                        unsigned int k, identical = 0;
@@ -73,8 +73,19 @@ int main(int argc, char *argv[])
                                ok1(!strstarts(strings[i], strings[j]));
                                ok1(!strends(reva, revb));
                        }
+                       free(reva);
+                       free(revb);
                }
        }
 
+       for (i = 0; i < n; i++)
+               free(strings[i]);
+
+       ok1(streq(stringify(NUM_SUBSTRINGS),
+                 "((sizeof(substrings) / sizeof(substrings[0])) - 1)"));
+       ok1(streq(stringify(ARRAY_SIZE(substrings)),
+                 "(sizeof(substrings) / sizeof(substrings[0]))"));
+       ok1(streq(stringify(i == 0), "i == 0"));
+
        return exit_status();
 }