Add comments describing the behavior of filters
This commit is contained in:
parent
2377c8d32b
commit
f5b4efef5f
@ -752,6 +752,7 @@ class Filter {
|
|||||||
std::vector<std::string> patterns_;
|
std::vector<std::string> patterns_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Constructs a filter form a string of patterns separated by `:`.
|
||||||
explicit Filter(const std::string& filter) {
|
explicit Filter(const std::string& filter) {
|
||||||
if (filter.empty()) return;
|
if (filter.empty()) return;
|
||||||
|
|
||||||
@ -766,6 +767,8 @@ class Filter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if and only if name matches at least one of the patterns in
|
||||||
|
// the filter.
|
||||||
bool MatchesName(const std::string& name) const {
|
bool MatchesName(const std::string& name) const {
|
||||||
const auto pattern_matches_name = [&name](const std::string& pattern) {
|
const auto pattern_matches_name = [&name](const std::string& pattern) {
|
||||||
return PatternMatchesString(name, pattern.c_str(),
|
return PatternMatchesString(name, pattern.c_str(),
|
||||||
@ -790,17 +793,24 @@ class PositiveAndNegativeFilter {
|
|||||||
filter.substr(dash_pos + 1)};
|
filter.substr(dash_pos + 1)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PositiveAndNegativeFilter(
|
PositiveAndNegativeFilter(
|
||||||
const std::pair<std::string, std::string>& positive_and_negative_filters)
|
const std::pair<std::string, std::string>& positive_and_negative_filters)
|
||||||
: positive_filter_(positive_and_negative_filters.first),
|
: positive_filter_(positive_and_negative_filters.first),
|
||||||
negative_filter_(positive_and_negative_filters.second) {}
|
negative_filter_(positive_and_negative_filters.second) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Constructs a positive and a negative filter from a string. The string
|
||||||
|
// contains a positive filter optionally followed by a '-' character and a
|
||||||
|
// negative filter. In case only a negative filter is provided the positive
|
||||||
|
// filter will be assumed "*".
|
||||||
|
// A filter is a list of patterns separated by ':'.
|
||||||
explicit PositiveAndNegativeFilter(const std::string& filter)
|
explicit PositiveAndNegativeFilter(const std::string& filter)
|
||||||
: PositiveAndNegativeFilter(BreakIntoPositiveAndNegativeFilters(filter)) {
|
: PositiveAndNegativeFilter(BreakIntoPositiveAndNegativeFilters(filter)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if and only if test name (this is generated by appending test
|
||||||
|
// suit name and test name via a '.' character) matches the positive filter
|
||||||
|
// and does not match the negative filter.
|
||||||
bool MatchesTest(const std::string& test_suite_name,
|
bool MatchesTest(const std::string& test_suite_name,
|
||||||
const std::string& test_name) const {
|
const std::string& test_name) const {
|
||||||
const std::string& full_name = test_suite_name + "." + test_name.c_str();
|
const std::string& full_name = test_suite_name + "." + test_name.c_str();
|
||||||
@ -808,6 +818,8 @@ class PositiveAndNegativeFilter {
|
|||||||
return MatchesName(full_name);
|
return MatchesName(full_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if and only if name matches the positive filter and does not
|
||||||
|
// match the negative filter.
|
||||||
bool MatchesName(const std::string& name) const {
|
bool MatchesName(const std::string& name) const {
|
||||||
return positive_filter_.MatchesName(name) &&
|
return positive_filter_.MatchesName(name) &&
|
||||||
!negative_filter_.MatchesName(name);
|
!negative_filter_.MatchesName(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user