3 test_description
='wildmatch tests'
10 test_expect_success
"wildmatch: match '$2' '$3'" "
11 test-wildmatch wildmatch '$2' '$3'
15 test_expect_success
"wildmatch: no match '$2' '$3'" "
16 test_must_fail test-wildmatch wildmatch '$2' '$3'
19 test_expect_success
"PANIC: Test framework error. Unknown matches value $1" 'false'
26 test_expect_success
"iwildmatch: match '$2' '$3'" "
27 test-wildmatch iwildmatch '$2' '$3'
31 test_expect_success
"iwildmatch: no match '$2' '$3'" "
32 test_must_fail test-wildmatch iwildmatch '$2' '$3'
35 test_expect_success
"PANIC: Test framework error. Unknown matches value $1" 'false'
42 test_expect_success
"pathmatch: match '$2' '$3'" "
43 test-wildmatch pathmatch '$2' '$3'
47 test_expect_success
"pathmatch: no match '$2' '$3'" "
48 test_must_fail test-wildmatch pathmatch '$2' '$3'
51 test_expect_success
"PANIC: Test framework error. Unknown matches value $1" 'false'
55 # Basic wildmat features
65 match
1 foobar
'*ob*a*r*'
66 match
1 aaaaaaabababab
'*ab'
67 match
1 'foo*' 'foo\*'
68 match
0 foobar
'foo\*bar'
69 match
1 'f\oo' 'f\\oo'
73 match
0 ten
'**[!ten]'
75 match
0 ten
't[!a-g]n'
76 match
1 ton
't[!a-g]n'
77 match
1 ton
't[^a-g]n'
80 match
1 'a]b' 'a[]-]b'
85 # Extended slash-matching features
86 match
0 'foo/baz/bar' 'foo*bar'
87 match
0 'foo/baz/bar' 'foo**bar'
88 match
0 'foobazbar' 'foo**bar'
89 match
1 'foo/baz/bar' 'foo/**/bar'
90 match
1 'foo/baz/bar' 'foo/**/**/bar'
91 match
1 'foo/b/a/z/bar' 'foo/**/bar'
92 match
1 'foo/b/a/z/bar' 'foo/**/**/bar'
93 match
1 'foo/bar' 'foo/**/bar'
94 match
1 'foo/bar' 'foo/**/**/bar'
95 match
0 'foo/bar' 'foo?bar'
96 match
0 'foo/bar' 'foo[/]bar'
97 match
0 'foo/bar' 'foo[^a-z]bar'
98 match
0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
99 match
1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
100 match
1 'foo' '**/foo'
101 match
1 'XXX/foo' '**/foo'
102 match
1 'bar/baz/foo' '**/foo'
103 match
0 'bar/baz/foo' '*/foo'
104 match
0 'foo/bar/baz' '**/bar*'
105 match
1 'deep/foo/bar/baz' '**/bar/*'
106 match
0 'deep/foo/bar/baz/' '**/bar/*'
107 match
1 'deep/foo/bar/baz/' '**/bar/**'
108 match
0 'deep/foo/bar' '**/bar/*'
109 match
1 'deep/foo/bar/' '**/bar/**'
110 match
0 'foo/bar/baz' '**/bar**'
111 match
1 'foo/bar/baz/x' '*/bar/**'
112 match
0 'deep/foo/bar/baz/x' '*/bar/**'
113 match
1 'deep/foo/bar/baz/x' '**/bar/*/*'
115 # Various additional tests
116 match
0 'acrt' 'a[c-c]st'
117 match
1 'acrt' 'a[c-c]rt'
122 match 0 'XXX
/\' '*/\'
123 match 1 'XXX
/\' '*/\\'
125 match
1 '@foo' '@foo'
127 match
1 '[ab]' '\[ab]'
128 match
1 '[ab]' '[[]ab]'
129 match
1 '[ab]' '[[:]ab]'
130 match
0 '[ab]' '[[::]ab]'
131 match
1 '[ab]' '[[:digit]ab]'
132 match
1 '[ab]' '[\[:]ab]'
133 match
1 '?a?b' '\??\?b'
134 match
1 'abc' '\a\b\c'
136 match
1 'foo/bar/baz/to' '**/t[o]'
138 # Character class tests
139 match
1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'
140 match
0 'a' '[[:digit:][:upper:][:space:]]'
141 match
1 'A' '[[:digit:][:upper:][:space:]]'
142 match
1 '1' '[[:digit:][:upper:][:space:]]'
143 match
0 '1' '[[:digit:][:upper:][:spaci:]]'
144 match
1 ' ' '[[:digit:][:upper:][:space:]]'
145 match
0 '.' '[[:digit:][:upper:][:space:]]'
146 match
1 '.' '[[:digit:][:punct:][:space:]]'
147 match
1 '5' '[[:xdigit:]]'
148 match
1 'f' '[[:xdigit:]]'
149 match
1 'D' '[[:xdigit:]]'
150 match
1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
151 match
1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'
152 match
1 '5' '[a-c[:digit:]x-z]'
153 match
1 'b' '[a-c[:digit:]x-z]'
154 match
1 'y' '[a-c[:digit:]x-z]'
155 match
0 'q' '[a-c[:digit:]x-z]'
157 # Additional tests, including some malformed wildmats
165 match 0 'a
[]b
' 'a
[]b
'
179 match 1 '-' '[------]'
180 match 0 'j
' '[a-e-n
]'
181 match 1 '-' '[a-e-n
]'
182 match 1 'a
' '[!------]'
188 match 1 '-b]' '[a-
]b
]'
193 match
0 'aaabbb' 'b*a'
194 match
0 'aabcaa' '*ba*'
200 match 0 '-.
]' '[,-.
]'
201 match 1 '2' '[\
1-\
3]'
202 match 1 '3' '[\
1-\
3]'
203 match 0 '4' '[\
1-\
3]'
209 # Test recursion and the abort code (use "wildtest -i" to see iteration counts)
210 match
1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
211 match
0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
212 match
0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
213 match
1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
214 match
0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
215 match
1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
216 match
0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
218 match
0 foo
/bar
'*/*/*'
219 match
1 foo
/bba
/arr
'*/*/*'
220 match
0 foo
/bb
/aa
/rr
'*/*/*'
221 match
1 foo
/bb
/aa
/rr
'**/**/**'
222 match
1 abcXdefXghi
'*X*i'
223 match
0 ab
/cXd
/efXg
/hi
'*X*i'
224 match
1 ab
/cXd
/efXg
/hi
'*/*X*/*/*i'
225 match
1 ab
/cXd
/efXg
/hi
'**/*X*/**/*i'
229 pathmatch
1 foo
/bar foo
/bar
230 pathmatch
1 foo
/bar
'foo/*'
231 pathmatch
1 foo
/bba
/arr
'foo/*'
232 pathmatch
1 foo
/bba
/arr
'foo/**'
233 pathmatch
1 foo
/bba
/arr
'foo*'
234 pathmatch
1 foo
/bba
/arr
'foo**'
235 pathmatch
1 foo
/bba
/arr
'foo/*arr'
236 pathmatch
1 foo
/bba
/arr
'foo/**arr'
237 pathmatch
0 foo
/bba
/arr
'foo/*z'
238 pathmatch
0 foo
/bba
/arr
'foo/**z'
239 pathmatch
1 foo
/bar
'foo?bar'
240 pathmatch
1 foo
/bar
'foo[/]bar'
241 pathmatch
1 foo
/bar
'foo[^a-z]bar'
242 pathmatch
0 foo
'*/*/*'
243 pathmatch
0 foo
/bar
'*/*/*'
244 pathmatch
1 foo
/bba
/arr
'*/*/*'
245 pathmatch
1 foo
/bb
/aa
/rr
'*/*/*'
246 pathmatch
1 abcXdefXghi
'*X*i'
247 pathmatch
1 ab
/cXd
/efXg
/hi
'*/*X*/*/*i'
248 pathmatch
1 ab
/cXd
/efXg
/hi
'*Xg*i'
250 # Case-sensitivity features
255 match
0 'a' '[[:upper:]]'
256 match
1 'A' '[[:upper:]]'
257 match
0 'A' '[[:lower:]]'
258 match
1 'a' '[[:lower:]]'
270 imatch
1 'a' '[[:upper:]]'
271 imatch
1 'A' '[[:upper:]]'
272 imatch
1 'A' '[[:lower:]]'
273 imatch
1 'a' '[[:lower:]]'
274 imatch
1 'A' '[B-Za]'
275 imatch
1 'a' '[B-Za]'