mirror of
https://github.com/google/googletest.git
synced 2025-01-15 00:47:54 +08:00
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_;
|
||||
|
||||
public:
|
||||
// Constructs a filter form a string of patterns separated by `:`.
|
||||
explicit Filter(const std::string& filter) {
|
||||
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 {
|
||||
const auto pattern_matches_name = [&name](const std::string& pattern) {
|
||||
return PatternMatchesString(name, pattern.c_str(),
|
||||
@ -790,17 +793,24 @@ class PositiveAndNegativeFilter {
|
||||
filter.substr(dash_pos + 1)};
|
||||
}
|
||||
}
|
||||
|
||||
PositiveAndNegativeFilter(
|
||||
const std::pair<std::string, std::string>& positive_and_negative_filters)
|
||||
: positive_filter_(positive_and_negative_filters.first),
|
||||
negative_filter_(positive_and_negative_filters.second) {}
|
||||
|
||||
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)
|
||||
: 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,
|
||||
const std::string& test_name) const {
|
||||
const std::string& full_name = test_suite_name + "." + test_name.c_str();
|
||||
@ -808,6 +818,8 @@ class PositiveAndNegativeFilter {
|
||||
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 {
|
||||
return positive_filter_.MatchesName(name) &&
|
||||
!negative_filter_.MatchesName(name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user