2 * ircd_match_t.c - test cases for irc glob matching
12 const char *should_match;
13 const char *shouldnt_match;
16 const struct match_test match_tests[] = {
21 "a\0pizza\0abe\0brack\0",
25 "*PeacefuL*\0pizza\0???\0" },
30 "abc\0fooabc\0ababc\0",
38 void do_match_test(const struct match_test *test)
40 const char *candidate;
41 unsigned int matched, not_matched;
44 for (candidate = test->should_match, matched = 0;
46 candidate += strlen(candidate) + 1, ++matched) {
47 res = match(test->glob, candidate);
49 fprintf(stderr, "\"%s\" failed to match \"%s\".\n", test->glob, candidate);
54 for (candidate = test->shouldnt_match, not_matched = 0;
56 candidate += strlen(candidate) + 1, ++not_matched) {
57 res = match(test->glob, candidate);
59 fprintf(stderr, "\"%s\" incorrectly matched \"%s\".\n", test->glob, candidate);
64 printf("Passed: %s (%u matches, %u non-matches)\n",
65 test->glob, matched, not_matched);
68 int main(int argc, char *argv[])
70 const struct match_test *match;
71 for (match = match_tests; match->glob; ++match)