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

Function test_realloc

ccan/ccan/bitmap/test/run-alloc.c:35–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35static void test_realloc(int obits, int nbits)
36{
37 bitmap *bitmap;
38 int i;
39 bool wrong;
40
41 bitmap = bitmap_alloc0(obits);
42 ok1(bitmap != NULL);
43 ok1(bitmap_empty(bitmap, obits));
44
45 bitmap = bitmap_realloc1(bitmap, obits, nbits);
46 ok1(bitmap != NULL);
47 if (obits < nbits)
48 ok1(bitmap_empty(bitmap, obits));
49 else
50 ok1(bitmap_empty(bitmap, nbits));
51
52 wrong = false;
53 for (i = obits; i < nbits; i++)
54 wrong = wrong || !bitmap_test_bit(bitmap, i);
55 ok1(!wrong);
56
57 free(bitmap);
58
59 bitmap = bitmap_alloc1(obits);
60 ok1(bitmap != NULL);
61 ok1(bitmap_full(bitmap, obits));
62
63 bitmap = bitmap_realloc0(bitmap, obits, nbits);
64 ok1(bitmap != NULL);
65 if (obits < nbits)
66 ok1(bitmap_full(bitmap, obits));
67 else
68 ok1(bitmap_full(bitmap, nbits));
69
70 wrong = false;
71 for (i = obits; i < nbits; i++)
72 wrong = wrong || bitmap_test_bit(bitmap, i);
73 ok1(!wrong);
74
75 free(bitmap);
76}
77
78int main(void)
79{

Callers 1

mainFunction · 0.70

Calls 7

bitmap_alloc0Function · 0.85
bitmap_emptyFunction · 0.85
bitmap_realloc1Function · 0.85
bitmap_test_bitFunction · 0.85
bitmap_alloc1Function · 0.85
bitmap_fullFunction · 0.85
bitmap_realloc0Function · 0.85

Tested by

no test coverage detected