Debian Codegraph @

.cargo/vendor/regex/testdata/bytes.toml

raw
1 # These are tests specifically crafted for regexes that can match arbitrary
2 # bytes. In some cases, we also test the Unicode variant as well, just because
3 # it's good sense to do so. But also, these tests aren't really about Unicode,
4 # but whether matches are only reported at valid UTF-8 boundaries. For most
5 # tests in this entire collection, utf8 = true. But for these tests, we use
6 # utf8 = false.
7
8 [[test]]
9 name = "word-boundary-ascii"
10 regex = ' \b'
11 haystack = " δ"
12 matches = []
13 unicode = false
14 utf8 = false
15
16 [[test]]
17 name = "word-boundary-unicode"
18 regex = ' \b'
19 haystack = " δ"
20 matches = [[0, 1]]
21 unicode = true
22 utf8 = false
23
24 [[test]]
25 name = "word-boundary-ascii-not"
26 regex = ' \B'
27 haystack = " δ"
28 matches = [[0, 1]]
29 unicode = false
30 utf8 = false
31
32 [[test]]
33 name = "word-boundary-unicode-not"
34 regex = ' \B'
35 haystack = " δ"
36 matches = []
37 unicode = true
38 utf8 = false
39
40 [[test]]
41 name = "perl-word-ascii"
42 regex = '\w+'
43 haystack = "aδ"
44 matches = [[0, 1]]
45 unicode = false
46 utf8 = false
47
48 [[test]]
49 name = "perl-word-unicode"
50 regex = '\w+'
51 haystack = "aδ"
52 matches = [[0, 3]]
53 unicode = true
54 utf8 = false
55
56 [[test]]
57 name = "perl-decimal-ascii"
58 regex = '\d+'
59 haystack = "1२३9"
60 matches = [[0, 1], [7, 8]]
61 unicode = false
62 utf8 = false
63
64 [[test]]
65 name = "perl-decimal-unicode"
66 regex = '\d+'
67 haystack = "1२३9"
68 matches = [[0, 8]]
69 unicode = true
70 utf8 = false
71
72 [[test]]
73 name = "perl-whitespace-ascii"
74 regex = '\s+'
75 haystack = " \u1680"
76 matches = [[0, 1]]
77 unicode = false
78 utf8 = false
79
80 [[test]]
81 name = "perl-whitespace-unicode"
82 regex = '\s+'
83 haystack = " \u1680"
84 matches = [[0, 4]]
85 unicode = true
86 utf8 = false
87
88 # The first `(.+)` matches two Unicode codepoints, but can't match the 5th
89 # byte, which isn't valid UTF-8. The second (byte based) `(.+)` takes over and
90 # matches.
91 [[test]]
92 name = "mixed-dot"
93 regex = '(.+)(?-u)(.+)'
94 haystack = '\xCE\x93\xCE\x94\xFF'
95 matches = [
96 [[0, 5], [0, 4], [4, 5]],
97 ]
98 unescape = true
99 unicode = true
100 utf8 = false
101
102 [[test]]
103 name = "case-one-ascii"
104 regex = 'a'
105 haystack = "A"
106 matches = [[0, 1]]
107 case-insensitive = true
108 unicode = false
109 utf8 = false
110
111 [[test]]
112 name = "case-one-unicode"
113 regex = 'a'
114 haystack = "A"
115 matches = [[0, 1]]
116 case-insensitive = true
117 unicode = true
118 utf8 = false
119
120 [[test]]
121 name = "case-class-simple-ascii"
122 regex = '[a-z]+'
123 haystack = "AaAaA"
124 matches = [[0, 5]]
125 case-insensitive = true
126 unicode = false
127 utf8 = false
128
129 [[test]]
130 name = "case-class-ascii"
131 regex = '[a-z]+'
132 haystack = "aA\u212AaA"
133 matches = [[0, 2], [5, 7]]
134 case-insensitive = true
135 unicode = false
136 utf8 = false
137
138 [[test]]
139 name = "case-class-unicode"
140 regex = '[a-z]+'
141 haystack = "aA\u212AaA"
142 matches = [[0, 7]]
143 case-insensitive = true
144 unicode = true
145 utf8 = false
146
147 [[test]]
148 name = "negate-ascii"
149 regex = '[^a]'
150 haystack = "δ"
151 matches = [[0, 1], [1, 2]]
152 unicode = false
153 utf8 = false
154
155 [[test]]
156 name = "negate-unicode"
157 regex = '[^a]'
158 haystack = "δ"
159 matches = [[0, 2]]
160 unicode = true
161 utf8 = false
162
163 # When utf8=true, this won't match, because the implicit '.*?' prefix is
164 # Unicode aware and will refuse to match through invalid UTF-8 bytes.
165 [[test]]
166 name = "dotstar-prefix-ascii"
167 regex = 'a'
168 haystack = '\xFFa'
169 matches = [[1, 2]]
170 unescape = true
171 unicode = false
172 utf8 = false
173
174 [[test]]
175 name = "dotstar-prefix-unicode"
176 regex = 'a'
177 haystack = '\xFFa'
178 matches = [[1, 2]]
179 unescape = true
180 unicode = true
181 utf8 = false
182
183 [[test]]
184 name = "null-bytes"
185 regex = '(?P<cstr>[^\x00]+)\x00'
186 haystack = 'foo\x00'
187 matches = [
188 [[0, 4], [0, 3]],
189 ]
190 unescape = true
191 unicode = false
192 utf8 = false
193
194 [[test]]
195 name = "invalid-utf8-anchor-100"
196 regex = '\xCC?^'
197 haystack = '\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4'
198 matches = [[0, 0]]
199 unescape = true
200 unicode = false
201 utf8 = false
202
203 [[test]]
204 name = "invalid-utf8-anchor-200"
205 regex = '^\xf7|4\xff\d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########[] d\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a\x8a##########\[] #####\x80\S7|$'
206 haystack = '\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4'
207 matches = [[22, 22]]
208 unescape = true
209 unicode = false
210 utf8 = false
211
212 [[test]]
213 name = "invalid-utf8-anchor-300"
214 regex = '^|ddp\xff\xffdddddlQd@\x80'
215 haystack = '\x8d#;\x1a\xa4s3\x05foobarX\\\x0f0t\xe4\x9b\xa4'
216 matches = [[0, 0]]
217 unescape = true
218 unicode = false
219 utf8 = false
220
221 [[test]]
222 name = "word-boundary-ascii-100"
223 regex = '\Bx\B'
224 haystack = "áxβ"
225 matches = []
226 unicode = false
227 utf8 = false
228
229 [[test]]
230 name = "word-boundary-ascii-200"
231 regex = '\B'
232 haystack = "0\U0007EF5E"
233 matches = [[2, 2], [3, 3], [4, 4], [5, 5]]
234 unicode = false
235 utf8 = false