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

Function test_feature_set_or

common/test/run-features.c:141–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141static void test_feature_set_or(void)
142{
143 struct feature_set *f1, *f2, *control;
144
145 /* cppcheck-suppress uninitvar - false positive on f1->bits */
146 for (size_t i = 0; i < ARRAY_SIZE(f1->bits); i++) {
147 f1 = talz(tmpctx, struct feature_set);
148 f2 = talz(tmpctx, struct feature_set);
149 control = talz(tmpctx, struct feature_set);
150
151 f1->bits[i] = tal_arr(f1, u8, 0);
152 f2->bits[i] = tal_arr(f2, u8, 0);
153 control->bits[i] = tal_arr(control, u8, 0);
154
155 /* or with nothing is a nop */
156 set_feature_bit(&f1->bits[i], 0);
157 set_feature_bit(&control->bits[i], 0);
158 assert(feature_set_or(f1, f2));
159 assert(feature_set_eq(f1, control));
160
161 /* or compulsory with either compulsory or optional is a fail */
162 set_feature_bit(&f2->bits[i], 0);
163 assert(!feature_set_or(f1, f2));
164 assert(feature_set_eq(f1, control));
165 assert(!feature_set_or(f2, f1));
166
167 clear_feature_bit(f2->bits[i], 0);
168 set_feature_bit(&f2->bits[i], 1);
169 assert(!feature_set_or(f1, f2));
170 assert(feature_set_eq(f1, control));
171 assert(!feature_set_or(f2, f1));
172
173 clear_feature_bit(f2->bits[i], 1);
174 set_feature_bit(&f2->bits[i], 10);
175 set_feature_bit(&control->bits[i], 10);
176 assert(feature_set_or(f1, f2));
177 assert(feature_set_eq(f1, control));
178 }
179}
180
181static void test_feature_set_sub(void)
182{

Callers 1

mainFunction · 0.85

Calls 4

set_feature_bitFunction · 0.85
feature_set_orFunction · 0.85
feature_set_eqFunction · 0.85
clear_feature_bitFunction · 0.85

Tested by

no test coverage detected