[test] fix bug in ExcludeIndividualFlags

PR #19168 introduced this function but it always returns an empty vector.
pull/826/head
glozow 4 years ago
parent 8cac2923f5
commit 8a365df558

@ -152,14 +152,17 @@ unsigned int FillFlags(unsigned int flags)
return flags;
}
// Return valid flags that are all except one flag for each flag
std::vector<unsigned int> ExcludeIndividualFlags(unsigned int flags)
// Exclude each possible script verify flag from flags. Returns a set of these flag combinations
// that are valid and without duplicates. For example: if flags=1111 and the 4 possible flags are
// 0001, 0010, 0100, and 1000, this should return the set {0111, 1011, 1101, 1110}.
// Assumes that mapFlagNames contains all script verify flags.
std::set<unsigned int> ExcludeIndividualFlags(unsigned int flags)
{
std::vector<unsigned int> flags_combos;
for (unsigned int i = 0; i < mapFlagNames.size(); ++i) {
const unsigned int flags_excluding_i = TrimFlags(flags & ~(1U << i));
if (flags != flags_excluding_i && std::find(flags_combos.begin(), flags_combos.end(), flags_excluding_i) != flags_combos.end()) {
flags_combos.push_back(flags_excluding_i);
std::set<unsigned int> flags_combos;
for (const auto& pair : mapFlagNames) {
const unsigned int flags_excluding_one = TrimFlags(flags & ~(pair.second));
if (flags != flags_excluding_one) {
flags_combos.insert(flags_excluding_one);
}
}
return flags_combos;

Loading…
Cancel
Save