FastLED 3.9.15
Loading...
Searching...
No Matches

◆ matchesFilter()

bool fl::test::TestContext::matchesFilter ( const char * name,
const char * filter ) const
private

Definition at line 161 of file fltest.cpp.hpp.

161 {
162 if (!filter || filter[0] == '\0') {
163 return true; // No filter means match all
164 }
165
166 // Simple wildcard matching: * matches any sequence, ? matches one char
167 const char* n = name;
168 const char* f = filter;
169
170 // Check if filter contains wildcards
171 bool hasWildcards = false;
172 for (const char* p = filter; *p; ++p) {
173 if (*p == '*' || *p == '?') {
174 hasWildcards = true;
175 break;
176 }
177 }
178
179 if (!hasWildcards) {
180 // No wildcards - do substring match
181 while (*n) {
182 const char* nn = n;
183 const char* ff = filter;
184 while (*nn && *ff && *nn == *ff) {
185 ++nn;
186 ++ff;
187 }
188 if (*ff == '\0') {
189 return true; // Found substring match
190 }
191 ++n;
192 }
193 return false;
194 }
195
196 // Wildcard matching using recursion simulation with stack
197 while (*f) {
198 if (*f == '*') {
199 ++f;
200 if (*f == '\0') {
201 return true; // Trailing * matches everything
202 }
203 // Try matching remaining pattern at each position
204 while (*n) {
205 if (matchesFilter(n, f)) {
206 return true;
207 }
208 ++n;
209 }
210 return false;
211 } else if (*f == '?') {
212 if (*n == '\0') {
213 return false; // ? needs a character to match
214 }
215 ++f;
216 ++n;
217 } else {
218 if (*n != *f) {
219 return false; // Literal mismatch
220 }
221 ++f;
222 ++n;
223 }
224 }
225
226 return *n == '\0'; // Both must be exhausted
227}
bool matchesFilter(const char *name, const char *filter) const FL_NOEXCEPT

References FL_NOEXCEPT, and matchesFilter().

Referenced by listTests(), matchesFilter(), and run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: