MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

ccan/ccan/tal/test/run-array.c:5–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <ccan/tap/tap.h>
4
5int main(void)
6{
7 char *parent, *c[4];
8 int i;
9
10 plan_tests(11);
11
12 parent = tal(NULL, char);
13 ok1(parent);
14
15 /* Zeroing allocations. */
16 for (i = 0; i < 4; i++) {
17 c[i] = talz(parent, char);
18 ok1(*c[i] == '\0');
19 tal_free(c[i]);
20 }
21
22 /* Array allocation. */
23 for (i = 0; i < 4; i++) {
24 c[i] = tal_arr(parent, char, 4);
25 strcpy(c[i], "abc");
26 tal_free(c[i]);
27 }
28
29 /* Zeroing array allocation. */
30 for (i = 0; i < 4; i++) {
31 c[i] = tal_arrz(parent, char, 4);
32 ok1(!c[i][0] && !c[i][1] && !c[i][2] && !c[i][3]);
33 strcpy(c[i], "abc");
34 tal_free(c[i]);
35 }
36
37 /* Resizing. */
38 c[0] = tal_arrz(parent, char, 4);
39 ok1(tal_resize(&c[0], 6));
40 strcpy(c[0], "hello");
41 tal_free(c[0]);
42 ok1(tal_first(parent) == NULL);
43
44 tal_free(parent);
45
46 tal_cleanup();
47 return exit_status();
48}

Callers

nothing calls this directly

Calls 3

tal_freeFunction · 0.85
tal_firstFunction · 0.85
tal_cleanupFunction · 0.85

Tested by

no test coverage detected