]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/talloc/test/run-count.c
tal/talloc: new module for backending tal onto talloc.
[ccan] / ccan / tal / talloc / test / run-count.c
diff --git a/ccan/tal/talloc/test/run-count.c b/ccan/tal/talloc/test/run-count.c
new file mode 100644 (file)
index 0000000..9e8a4e7
--- /dev/null
@@ -0,0 +1,33 @@
+#include <ccan/tal/talloc/talloc.h>
+#include <ccan/tal/talloc/talloc.c>
+#include <ccan/tap/tap.h>
+
+int main(void)
+{
+       char *p1, *p2;
+
+       plan_tests(12);
+
+       p1 = tal(NULL, char);
+       ok1(p1);
+       ok1(tal_count(p1) == 1);
+
+       p2 = tal_arr(p1, char, 1);
+       ok1(p2);
+       ok1(tal_count(p2) == 1);
+       ok1(tal_resize(&p2, 2));
+       ok1(tal_count(p2) == 2);
+       ok1(tal_check(NULL, NULL));
+       tal_free(p2);
+
+       p2 = tal_arrz(p1, char, 7);
+       ok1(p2);
+       ok1(tal_count(p2) == 7);
+       ok1(tal_resize(&p2, 0));
+       ok1(tal_count(p2) == 0);
+       ok1(tal_check(NULL, NULL));
+       tal_free(p2);
+       tal_free(p1);
+
+       return exit_status();
+}