diff options
Diffstat (limited to 'googletest/src/gtest.cc')
-rw-r--r-- | googletest/src/gtest.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index be97b2d..c2e40f8 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -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); |