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

Function test_feature_set_sub

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

Source from the content-addressed store, hash-verified

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

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