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

Function test_feature_set_sub

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

Source from the content-addressed store, hash-verified

179}
180
181static void test_feature_set_sub(void)
182{
183 struct feature_set *f1, *f2, *control;
184
185 /* cppcheck-suppress uninitvar - false positive on f1->bits */
186 for (size_t i = 0; i < ARRAY_SIZE(f1->bits); i++) {
187 f1 = talz(tmpctx, struct feature_set);
188 f2 = talz(tmpctx, struct feature_set);
189 control = talz(tmpctx, struct feature_set);
190
191 f1->bits[i] = tal_arr(f1, u8, 0);
192 f2->bits[i] = tal_arr(f2, u8, 0);
193 control->bits[i] = tal_arr(control, u8, 0);
194
195 /* sub with nothing is a nop */
196 set_feature_bit(&f1->bits[i], 0);
197 set_feature_bit(&control->bits[i], 0);
198 assert(feature_set_eq(f1, control));
199 assert(feature_set_sub(f1, f2));
200
201 /* can't sub feature bit that's not set */
202 set_feature_bit(&f2->bits[i], 2);
203 assert(!feature_set_sub(f1, f2));
204 assert(feature_set_eq(f1, control));
205 assert(!feature_set_sub(f2, f1));
206
207 /* sub does the right thing */
208 set_feature_bit(&f1->bits[i], 2);
209 assert(feature_set_sub(f1, f2));
210 assert(feature_set_eq(f1, control));
211 assert(!feature_set_sub(f1, f2));
212 }
213}
214
215static void test_feature_trim(void)
216{

Callers 1

mainFunction · 0.85

Calls 3

set_feature_bitFunction · 0.85
feature_set_eqFunction · 0.85
feature_set_subFunction · 0.85

Tested by

no test coverage detected