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

Function test_sizes

ccan/ccan/bitmap/test/run.c:17–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#define NTESTS 9
16
17static void test_sizes(int nbits, bool dynalloc)
18{
19 BITMAP_DECLARE(sbitmap, nbits);
20 uint32_t marker;
21 bitmap *bitmap;
22 int i, j;
23 bool wrong;
24
25 if (dynalloc) {
26 bitmap = bitmap_alloc(nbits);
27 ok1(bitmap != NULL);
28 } else {
29 bitmap = sbitmap;
30 marker = 0xdeadbeef;
31 }
32
33 bitmap_zero(bitmap, nbits);
34 wrong = false;
35 for (i = 0; i < nbits; i++) {
36 wrong = wrong || bitmap_test_bit(bitmap, i);
37 }
38 ok1(!wrong);
39
40 bitmap_fill(bitmap, nbits);
41 wrong = false;
42 for (i = 0; i < nbits; i++) {
43 wrong = wrong || !bitmap_test_bit(bitmap, i);
44 }
45 ok1(!wrong);
46
47 wrong = false;
48 for (i = 0; i < nbits; i++) {
49 bitmap_zero(bitmap, nbits);
50 bitmap_set_bit(bitmap, i);
51 for (j = 0; j < nbits; j++) {
52 bool val = (i == j);
53
54 wrong = wrong || (bitmap_test_bit(bitmap, j) != val);
55 }
56 }
57 ok1(!wrong);
58
59 wrong = false;
60 for (i = 0; i < nbits; i++) {
61 bitmap_fill(bitmap, nbits);
62 bitmap_clear_bit(bitmap, i);
63 for (j = 0; j < nbits; j++) {
64 bool val = !(i == j);
65
66 wrong = wrong || (bitmap_test_bit(bitmap, j) != val);
67 }
68 }
69 ok1(!wrong);
70
71 bitmap_zero(bitmap, nbits);
72 ok1(bitmap_empty(bitmap, nbits));
73
74 wrong = false;

Callers 1

mainFunction · 0.85

Calls 8

bitmap_allocFunction · 0.85
bitmap_zeroFunction · 0.85
bitmap_test_bitFunction · 0.85
bitmap_fillFunction · 0.85
bitmap_set_bitFunction · 0.85
bitmap_clear_bitFunction · 0.85
bitmap_emptyFunction · 0.85
bitmap_fullFunction · 0.85

Tested by

no test coverage detected