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 },
16 { "a/b", "*", FNM_PATHNAME
, FNM_NOMATCH
},
17 { "a/b", "*[/]b", FNM_PATHNAME
, FNM_NOMATCH
},
18 { "a/b", "*[b]", FNM_PATHNAME
, FNM_NOMATCH
},
19 { "a/b", "[*]/b", 0, FNM_NOMATCH
},
20 { "*/b", "[*]/b", 0, 0 },
21 { "a/b", "[?]/b", 0, FNM_NOMATCH
},
22 { "?/b", "[?]/b", 0, 0 },
23 { "a/b", "[[a]/b", 0, 0 },
24 { "[/b", "[[a]/b", 0, 0 },
25 { "a/b", "\\*/b", 0, FNM_NOMATCH
},
26 { "*/b", "\\*/b", 0, 0 },
27 { "a/b", "\\?/b", 0, FNM_NOMATCH
},
28 { "?/b", "\\?/b", 0, 0 },
29 { "[/b", "[/b", 0, FNM_NOMATCH
},
30 { "[/b", "\\[/b", 0, 0 },
31 { "aa/b", "?""?/b", 0, 0 },
32 { "aa/b", "?""?""?b", 0, 0 },
33 { "aa/b", "?""?""?b", FNM_PATHNAME
, FNM_NOMATCH
},
34 { ".a/b", "?a/b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
35 { "a/.b", "a/?b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
36 { ".a/b", "*a/b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
37 { "a/.b", "a/*b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
38 { ".a/b", "[.]a/b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
39 { "a/.b", "a/[.]b", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
40 { "a/b", "*/?", FNM_PATHNAME
|FNM_PERIOD
, 0 },
41 { "a/b", "?/*", FNM_PATHNAME
|FNM_PERIOD
, 0 },
42 { ".a/b", ".*/?", FNM_PATHNAME
|FNM_PERIOD
, 0 },
43 { "a/.b", "*/.?", FNM_PATHNAME
|FNM_PERIOD
, 0 },
44 { "a/.b", "*/*", FNM_PATHNAME
|FNM_PERIOD
, FNM_NOMATCH
},
45 { "a/.b", "*?*/*", FNM_PERIOD
, 0 },
46 { "a./b", "*[.]/b", FNM_PATHNAME
|FNM_PERIOD
, 0 },
47 { "a/b", "*[[:alpha:]]/*[[:alnum:]]", FNM_PATHNAME
, 0 },
48 { "a/b", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME
, 0 },
49 { "a/[", "*[![:digit:]]*/[[:d-d]", FNM_PATHNAME
, 0 },
50 { "a/[", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME
, FNM_NOMATCH
},
51 { "a.b", "a?b", FNM_PATHNAME
|FNM_PERIOD
, 0 },
52 { "a.b", "a*b", FNM_PATHNAME
|FNM_PERIOD
, 0 },
53 { "a.b", "a[.]b", FNM_PATHNAME
|FNM_PERIOD
, 0 },
54 { "a/b", "*a*", FNM_PATHNAME
|FNM_LEADING_DIR
, 0 },
55 { "ab/c", "*a?", FNM_PATHNAME
|FNM_LEADING_DIR
, 0 },
56 { "ab/c", "a?", FNM_PATHNAME
|FNM_LEADING_DIR
, 0 },
65 for (i
= 0; i
< sizeof (tests
) / sizeof (*tests
); i
++)
69 match
= fnmatch (tests
[i
].pattern
, tests
[i
].name
, tests
[i
].flags
);
71 printf ("[%2zd] %s %s %s -> %s\n", i
, tests
[i
].pattern
,
72 match
== 0 ? "matches" : "does not match",
74 match
!= tests
[i
].expected
? "FAIL" : "OK");
76 if (match
!= tests
[i
].expected
)