FastLED 3.10.8
Loading...
Searching...
No Matches

◆ matchesFilter()

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

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

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

References fl::FL_NO_EXCEPT, and matchesFilter().

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

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