3 test_description
='wildmatch tests'
10 test_expect_success
"wildmatch: match '$3' '$4'" "
11 test-wildmatch wildmatch '$3' '$4'
14 test_expect_success
"wildmatch: no match '$3' '$4'" "
15 ! test-wildmatch wildmatch '$3' '$4'
23 test_expect_success
"iwildmatch: match '$2' '$3'" "
24 test-wildmatch iwildmatch '$2' '$3'
27 test_expect_success
"iwildmatch: no match '$2' '$3'" "
28 ! test-wildmatch iwildmatch '$2' '$3'
36 test_expect_success
"pathmatch: match '$2' '$3'" "
37 test-wildmatch pathmatch '$2' '$3'
40 test_expect_success
"pathmatch: no match '$2' '$3'" "
41 ! test-wildmatch pathmatch '$2' '$3'
46 # Basic wildmat features
56 match
1 1 foobar
'*ob*a*r*'
57 match
1 1 aaaaaaabababab
'*ab'
58 match
1 1 'foo*' 'foo\*'
59 match
0 0 foobar
'foo\*bar'
60 match
1 1 'f\oo' 'f\\oo'
61 match
1 1 ball
'*[al]?'
63 match
0 1 ten
'**[!te]'
64 match
0 0 ten
'**[!ten]'
65 match
1 1 ten
't[a-g]n'
66 match
0 0 ten
't[!a-g]n'
67 match
1 1 ton
't[!a-g]n'
68 match
1 1 ton
't[^a-g]n'
69 match
1 x
'a]b' 'a[]]b'
70 match
1 x a-b
'a[]-]b'
71 match
1 x
'a]b' 'a[]-]b'
72 match
0 x aab
'a[]-]b'
73 match
1 x aab
'a[]a-]b'
76 # Extended slash-matching features
77 match
0 0 'foo/baz/bar' 'foo*bar'
78 match
0 0 'foo/baz/bar' 'foo**bar'
79 match
0 1 'foobazbar' 'foo**bar'
80 match
1 1 'foo/baz/bar' 'foo/**/bar'
81 match
1 0 'foo/baz/bar' 'foo/**/**/bar'
82 match
1 0 'foo/b/a/z/bar' 'foo/**/bar'
83 match
1 0 'foo/b/a/z/bar' 'foo/**/**/bar'
84 match
1 0 'foo/bar' 'foo/**/bar'
85 match
1 0 'foo/bar' 'foo/**/**/bar'
86 match
0 0 'foo/bar' 'foo?bar'
87 match
0 0 'foo/bar' 'foo[/]bar'
88 match
0 0 'foo/bar' 'foo[^a-z]bar'
89 match
0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
90 match
1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
91 match
1 0 'foo' '**/foo'
92 match
1 x
'XXX/foo' '**/foo'
93 match
1 0 'bar/baz/foo' '**/foo'
94 match
0 0 'bar/baz/foo' '*/foo'
95 match
0 0 'foo/bar/baz' '**/bar*'
96 match
1 0 'deep/foo/bar/baz' '**/bar/*'
97 match
0 0 'deep/foo/bar/baz/' '**/bar/*'
98 match
1 0 'deep/foo/bar/baz/' '**/bar/**'
99 match
0 0 'deep/foo/bar' '**/bar/*'
100 match
1 0 'deep/foo/bar/' '**/bar/**'
101 match
0 0 'foo/bar/baz' '**/bar**'
102 match
1 0 'foo/bar/baz/x' '*/bar/**'
103 match
0 0 'deep/foo/bar/baz/x' '*/bar/**'
104 match
1 0 'deep/foo/bar/baz/x' '**/bar/*/*'
106 # Various additional tests
107 match
0 0 'acrt' 'a[c-c]st'
108 match
1 1 'acrt' 'a[c-c]rt'
109 match
0 0 ']' '[!]-]'
110 match
1 x
'a' '[!]-]'
113 match 0 x 'XXX
/\' '*/\'
114 match 1 x 'XXX
/\' '*/\\'
115 match
1 1 'foo' 'foo'
116 match
1 1 '@foo' '@foo'
117 match
0 0 'foo' '@foo'
118 match
1 1 '[ab]' '\[ab]'
119 match
1 1 '[ab]' '[[]ab]'
120 match
1 x
'[ab]' '[[:]ab]'
121 match
0 x
'[ab]' '[[::]ab]'
122 match
1 x
'[ab]' '[[:digit]ab]'
123 match
1 x
'[ab]' '[\[:]ab]'
124 match
1 1 '?a?b' '\??\?b'
125 match
1 1 'abc' '\a\b\c'
127 match
1 0 'foo/bar/baz/to' '**/t[o]'
129 # Character class tests
130 match
1 x
'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'
131 match
0 x
'a' '[[:digit:][:upper:][:space:]]'
132 match
1 x
'A' '[[:digit:][:upper:][:space:]]'
133 match
1 x
'1' '[[:digit:][:upper:][:space:]]'
134 match
0 x
'1' '[[:digit:][:upper:][:spaci:]]'
135 match
1 x
' ' '[[:digit:][:upper:][:space:]]'
136 match
0 x
'.' '[[:digit:][:upper:][:space:]]'
137 match
1 x
'.' '[[:digit:][:punct:][:space:]]'
138 match
1 x
'5' '[[:xdigit:]]'
139 match
1 x
'f' '[[:xdigit:]]'
140 match
1 x
'D' '[[:xdigit:]]'
141 match
1 x
'_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
142 match
1 x
'.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'
143 match
1 x
'5' '[a-c[:digit:]x-z]'
144 match
1 x
'b' '[a-c[:digit:]x-z]'
145 match
1 x
'y' '[a-c[:digit:]x-z]'
146 match
0 x
'q' '[a-c[:digit:]x-z]'
148 # Additional tests, including some malformed wildmats
149 match
1 x
']' '[\\-^]'
150 match
0 0 '[' '[\\-^]'
151 match
1 x
'-' '[\-_]'
153 match
0 0 '\]' '[\]]'
155 match 0 0 'ab
' 'a
[]b
'
156 match 0 x 'a
[]b
' 'a
[]b
'
157 match 0 x 'ab
[' 'ab
['
163 match 1 x '-' '[--A]'
164 match 1 x '5' '[--A]'
165 match 1 1 ' ' '[ --]'
166 match 1 1 '$
' '[ --]'
167 match 1 1 '-' '[ --]'
168 match 0 0 '0' '[ --]'
169 match 1 x '-' '[---]'
170 match 1 x '-' '[------]'
171 match 0 0 'j
' '[a-e-n
]'
172 match 1 x '-' '[a-e-n
]'
173 match 1 x 'a
' '[!------]'
174 match 0 0 '[' '[]-a]'
175 match 1 x '^
' '[]-a]'
176 match 0 0 '^
' '[!]-a]'
177 match 1 x '[' '[!]-a]'
178 match 1 1 '^
' '[a^
bc]'
179 match 1 x '-b]' '[a-
]b
]'
182 match 0 0 '\' '[!\\]'
183 match
1 1 'G' '[A-\\]'
184 match
0 0 'aaabbb' 'b*a'
185 match
0 0 'aabcaa' '*ba*'
187 match
1 1 ',' '[\\,]'
188 match
1 1 '\' '[\\,]'
189 match 1 1 '-' '[,-.
]'
190 match 0 0 '+' '[,-.
]'
191 match 0 0 '-.
]' '[,-.
]'
192 match 1 1 '2' '[\
1-\
3]'
193 match 1 1 '3' '[\
1-\
3]'
194 match 0 0 '4' '[\
1-\
3]'
195 match 1 1 '\' '[[-\]]'
196 match
1 1 '[' '[[-\]]'
197 match
1 1 ']' '[[-\]]'
198 match
0 0 '-' '[[-\]]'
200 # Test recursion and the abort code (use "wildtest -i" to see iteration counts)
201 match
1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
202 match
0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
203 match
0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
204 match
1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
205 match
0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
206 match
1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
207 match
0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
208 match
0 x foo
'*/*/*'
209 match
0 x foo
/bar
'*/*/*'
210 match
1 x foo
/bba
/arr
'*/*/*'
211 match
0 x foo
/bb
/aa
/rr
'*/*/*'
212 match
1 x foo
/bb
/aa
/rr
'**/**/**'
213 match
1 x abcXdefXghi
'*X*i'
214 match
0 x ab
/cXd
/efXg
/hi
'*X*i'
215 match
1 x ab
/cXd
/efXg
/hi
'*/*X*/*/*i'
216 match
1 x ab
/cXd
/efXg
/hi
'**/*X*/**/*i'
220 pathmatch
1 foo
/bar foo
/bar
221 pathmatch
1 foo
/bar
'foo/*'
222 pathmatch
1 foo
/bba
/arr
'foo/*'
223 pathmatch
1 foo
/bba
/arr
'foo/**'
224 pathmatch
1 foo
/bba
/arr
'foo*'
225 pathmatch
1 foo
/bba
/arr
'foo**'
226 pathmatch
1 foo
/bba
/arr
'foo/*arr'
227 pathmatch
1 foo
/bba
/arr
'foo/**arr'
228 pathmatch
0 foo
/bba
/arr
'foo/*z'
229 pathmatch
0 foo
/bba
/arr
'foo/**z'
230 pathmatch
1 foo
/bar
'foo?bar'
231 pathmatch
1 foo
/bar
'foo[/]bar'
232 pathmatch
1 foo
/bar
'foo[^a-z]bar'
233 pathmatch
0 foo
'*/*/*'
234 pathmatch
0 foo
/bar
'*/*/*'
235 pathmatch
1 foo
/bba
/arr
'*/*/*'
236 pathmatch
1 foo
/bb
/aa
/rr
'*/*/*'
237 pathmatch
1 abcXdefXghi
'*X*i'
238 pathmatch
1 ab
/cXd
/efXg
/hi
'*/*X*/*/*i'
239 pathmatch
1 ab
/cXd
/efXg
/hi
'*Xg*i'
241 # Case-sensitivity features
242 match
0 x
'a' '[A-Z]'
243 match
1 x
'A' '[A-Z]'
244 match
0 x
'A' '[a-z]'
245 match
1 x
'a' '[a-z]'
246 match
0 x
'a' '[[:upper:]]'
247 match
1 x
'A' '[[:upper:]]'
248 match
0 x
'A' '[[:lower:]]'
249 match
1 x
'a' '[[:lower:]]'
250 match
0 x
'A' '[B-Za]'
251 match
1 x
'a' '[B-Za]'
252 match
0 x
'A' '[B-a]'
253 match
1 x
'a' '[B-a]'
254 match
0 x
'z' '[Z-y]'
255 match
1 x
'Z' '[Z-y]'
261 imatch
1 'a' '[[:upper:]]'
262 imatch
1 'A' '[[:upper:]]'
263 imatch
1 'A' '[[:lower:]]'
264 imatch
1 'a' '[[:lower:]]'
265 imatch
1 'A' '[B-Za]'
266 imatch
1 'a' '[B-Za]'