Skip to content

Commit

Permalink
Fix regression: filter should give exclude precedence. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
DefaultRyan authored Jun 30, 2021
1 parent 866c5f4 commit 7abd21d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/impl/winmd_reader/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace winmd::reader

std::sort(m_rules.begin(), m_rules.end(), [](auto const& lhs, auto const& rhs)
{
return std::pair{ lhs.first.size(), lhs.second } > std::pair{ rhs.first.size(), rhs.second };
return std::pair{ lhs.first.size(), !lhs.second } > std::pair{ rhs.first.size(), !rhs.second };
});
}

Expand Down
12 changes: 12 additions & 0 deletions test/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ TEST_CASE("filter_excludes_same_length")
REQUIRE(!f.includes("N.N3.T"));
REQUIRE(!f.includes("N.N4.T"));
}

TEST_CASE("filter_exclude_include_precedence")
{
std::vector<std::string> include = { "N.T" };
std::vector<std::string> exclude = { "N.T" };

filter f{ include, exclude };

REQUIRE(!f.empty());

REQUIRE(!f.includes("N.T"));
}

0 comments on commit 7abd21d

Please sign in to comment.