]> git.ozlabs.org Git - ccan/blob - ccan/tal/test/run-overflow.c
tal: new module.
[ccan] / ccan / tal / test / run-overflow.c
1 #include <ccan/tal/tal.h>
2 #include <ccan/tal/tal.c>
3 #include <ccan/tap/tap.h>
4
5 static int error_count;
6
7 static void my_error(const char *msg)
8 {
9         error_count++;
10         ok1(strstr(msg, "overflow"));
11 }
12
13 int main(void)
14 {
15         void *p;
16
17         plan_tests(6);
18
19         tal_set_backend(NULL, NULL, NULL, my_error);
20
21         p = tal_arr(NULL, int, (size_t)-1);
22         ok1(!p);
23         ok1(error_count == 1);
24
25         p = tal_arr(NULL, char, (size_t)-2);
26         ok1(!p);
27         ok1(error_count == 2);
28         return exit_status();
29 }