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

Function test_feature_set_or

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

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls 4

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

Tested by

no test coverage detected