diff options
author | Hossein Ghahramanzadeh <hgsilverman@gmail.com> | 2021-10-17 16:44:54 (GMT) |
---|---|---|
committer | Hossein Ghahramanzadeh <hgsilverman@gmail.com> | 2022-01-06 14:46:52 (GMT) |
commit | f5b4efef5f6a190c50437a81c2c4bfb1996eeb50 (patch) | |
tree | 60d833bd4767a639aa5caf064f528bd48cfd996c /googletest/src | |
parent | 2377c8d32b82239a29bc81f452ab2875de810b2f (diff) | |
download | googletest-f5b4efef5f6a190c50437a81c2c4bfb1996eeb50.zip googletest-f5b4efef5f6a190c50437a81c2c4bfb1996eeb50.tar.gz googletest-f5b4efef5f6a190c50437a81c2c4bfb1996eeb50.tar.bz2 |
Add comments describing the behavior of filters
Diffstat (limited to 'googletest/src')
-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); |