summaryrefslogtreecommitdiff
path: root/ccan/tal/test/run-expand.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-09 12:10:32 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-09 12:10:32 -0700
commit1b8fbbd843ddeb5fc81c9303db9c590a436d499b (patch)
treea7227dfe8e4fbaee7b1e0b58b24994dce8078f3f /ccan/tal/test/run-expand.c
parent37a9cdd2e80386f2c94e14e4f511284ae14c745a (diff)
progress
Diffstat (limited to 'ccan/tal/test/run-expand.c')
-rw-r--r--ccan/tal/test/run-expand.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/ccan/tal/test/run-expand.c b/ccan/tal/test/run-expand.c
new file mode 100644
index 0000000..841735f
--- /dev/null
+++ b/ccan/tal/test/run-expand.c
@@ -0,0 +1,33 @@
+#include <ccan/tal/tal.h>
+#include <ccan/tal/tal.c>
+#include <ccan/tap/tap.h>
+
+int main(void)
+{
+ int *a;
+ const int arr[] = { 1, 2 };
+
+ plan_tests(13);
+
+ a = tal_arrz(NULL, int, 1);
+ ok1(a);
+
+ ok1(tal_expand(&a, arr, 2));
+ ok1(tal_count(a) == 3);
+ ok1(a[0] == 0);
+ ok1(a[1] == 1);
+ ok1(a[2] == 2);
+
+ ok1(tal_expand(&a, take(tal_arrz(NULL, int, 1)), 1));
+ ok1(tal_count(a) == 4);
+ ok1(a[0] == 0);
+ ok1(a[1] == 1);
+ ok1(a[2] == 2);
+ ok1(a[3] == 0);
+ ok1(tal_first(NULL) == a && !tal_next(a) && !tal_first(a));
+
+ tal_free(a);
+
+ tal_cleanup();
+ return exit_status();
+}