| 174 | } |
| 175 | |
| 176 | static 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 | |
| 210 | static void test_feature_trim(void) |
| 211 | { |
no test coverage detected