OLD | NEW |
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (param_name == "*") | 76 if (param_name == "*") |
77 return kTupleInterpolation; | 77 return kTupleInterpolation; |
78 | 78 |
79 for (int i = 0; param_names[i] != NULL; i++) { | 79 for (int i = 0; param_names[i] != NULL; i++) { |
80 if (param_name == param_names[i]) | 80 if (param_name == param_names[i]) |
81 return i; | 81 return i; |
82 } | 82 } |
83 return kInvalidInterpolation; | 83 return kInvalidInterpolation; |
84 } | 84 } |
85 | 85 |
86 // If *pstr starts with the given prefix, modifies *pstr to be right | |
87 // past the prefix and returns true; otherwise leaves *pstr unchanged | |
88 // and returns false. None of pstr, *pstr, and prefix can be NULL. | |
89 bool SkipPrefix(const char* prefix, const char** pstr) { | |
90 const size_t prefix_len = strlen(prefix); | |
91 if (strncmp(*pstr, prefix, prefix_len) == 0) { | |
92 *pstr += prefix_len; | |
93 return true; | |
94 } | |
95 return false; | |
96 } | |
97 | |
98 // Helper function used by ValidateMatcherDescription() to format | 86 // Helper function used by ValidateMatcherDescription() to format |
99 // error messages. | 87 // error messages. |
100 string FormatMatcherDescriptionSyntaxError(const char* description, | 88 string FormatMatcherDescriptionSyntaxError(const char* description, |
101 const char* error_pos) { | 89 const char* error_pos) { |
102 ::std::stringstream ss; | 90 ::std::stringstream ss; |
103 ss << "Syntax error at index " << (error_pos - description) | 91 ss << "Syntax error at index " << (error_pos - description) |
104 << " in matcher description \"" << description << "\": "; | 92 << " in matcher description \"" << description << "\": "; |
105 return ss.str(); | 93 return ss.str(); |
106 } | 94 } |
107 | 95 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 last_interp_end = interp[i].end_pos; | 181 last_interp_end = interp[i].end_pos; |
194 } | 182 } |
195 result += last_interp_end; | 183 result += last_interp_end; |
196 } | 184 } |
197 | 185 |
198 return result; | 186 return result; |
199 } | 187 } |
200 | 188 |
201 } // namespace internal | 189 } // namespace internal |
202 } // namespace testing | 190 } // namespace testing |
OLD | NEW |