MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / PatternMatchesString

Method PatternMatchesString

tests/gtest/gtest-all.cc:1970–1985  ·  view source on GitHub ↗

Returns true iff the wildcard pattern matches the string. The first ':' or '\0' character in pattern marks the end of it. This recursive algorithm isn't very efficient, but is clear and works well enough for matching test names, which are short.

Source from the content-addressed store, hash-verified

1968// This recursive algorithm isn't very efficient, but is clear and
1969// works well enough for matching test names, which are short.
1970bool UnitTestOptions::PatternMatchesString(const char *pattern,
1971 const char *str) {
1972 switch (*pattern) {
1973 case '\0':
1974 case ':': // Either ':' or '\0' marks the end of the pattern.
1975 return *str == '\0';
1976 case '?': // Matches any single character.
1977 return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
1978 case '*': // Matches any string (possibly empty) of characters.
1979 return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
1980 PatternMatchesString(pattern + 1, str);
1981 default: // Non-special character. Matches itself.
1982 return *pattern == *str &&
1983 PatternMatchesString(pattern + 1, str + 1);
1984 }
1985}
1986
1987bool UnitTestOptions::MatchesFilter(
1988 const std::string& name, const char* filter) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected