Update.
[glibc.git] / posix / testfnm.c
blob5ab761b8b23a60d11effce0e43ce28223b91ecd5
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "fnmatch.h"
5 struct {
6 const char *name;
7 const char *pattern;
8 int flags;
9 int expected;
10 } tests[] = {
11 { "lib", "*LIB*", FNM_PERIOD, FNM_NOMATCH },
12 { "lib", "*LIB*", FNM_CASEFOLD|FNM_PERIOD, 0 },
13 { "a/b", "a[/]b", 0, 0 },
14 { "a/b", "a[/]b", FNM_PATHNAME, FNM_NOMATCH },
15 { "a/b", "[a-z]/[a-z]", 0, 0 },
18 int
19 main (void)
21 size_t i;
22 int errors = 0;
24 for (i = 0; i < sizeof (tests) / sizeof (*tests); i++)
26 int match;
28 match = fnmatch (tests[i].pattern, tests[i].name, tests[i].flags);
29 if (match != tests[i].expected)
31 printf ("%s %s %s\n", tests[i].pattern,
32 match == 0 ? "matches" : "does not match",
33 tests[i].name);
34 errors++;
38 exit (errors != 0);