Debian Codegraph @

.cargo/vendor/regex/testdata/no-unicode.toml

raw
1 [[test]]
2 name = "invalid-utf8-literal1"
3 regex = '\xFF'
4 haystack = '\xFF'
5 matches = [[0, 1]]
6 unicode = false
7 utf8 = false
8 unescape = true
9
10
11 [[test]]
12 name = "mixed"
13 regex = '(?:.+)(?-u)(?:.+)'
14 haystack = '\xCE\x93\xCE\x94\xFF'
15 matches = [[0, 5]]
16 utf8 = false
17 unescape = true
18
19
20 [[test]]
21 name = "case1"
22 regex = "a"
23 haystack = "A"
24 matches = [[0, 1]]
25 case-insensitive = true
26 unicode = false
27
28 [[test]]
29 name = "case2"
30 regex = "[a-z]+"
31 haystack = "AaAaA"
32 matches = [[0, 5]]
33 case-insensitive = true
34 unicode = false
35
36 [[test]]
37 name = "case3"
38 regex = "[a-z]+"
39 haystack = "aA\u212AaA"
40 matches = [[0, 7]]
41 case-insensitive = true
42
43 [[test]]
44 name = "case4"
45 regex = "[a-z]+"
46 haystack = "aA\u212AaA"
47 matches = [[0, 2], [5, 7]]
48 case-insensitive = true
49 unicode = false
50
51
52 [[test]]
53 name = "negate1"
54 regex = "[^a]"
55 haystack = "δ"
56 matches = [[0, 2]]
57
58 [[test]]
59 name = "negate2"
60 regex = "[^a]"
61 haystack = "δ"
62 matches = [[0, 1], [1, 2]]
63 unicode = false
64 utf8 = false
65
66
67 [[test]]
68 name = "dotstar-prefix1"
69 regex = "a"
70 haystack = '\xFFa'
71 matches = [[1, 2]]
72 unicode = false
73 utf8 = false
74 unescape = true
75
76 [[test]]
77 name = "dotstar-prefix2"
78 regex = "a"
79 haystack = '\xFFa'
80 matches = [[1, 2]]
81 utf8 = false
82 unescape = true
83
84
85 [[test]]
86 name = "null-bytes1"
87 regex = '[^\x00]+\x00'
88 haystack = 'foo\x00'
89 matches = [[0, 4]]
90 unicode = false
91 utf8 = false
92 unescape = true
93
94
95 [[test]]
96 name = "word-ascii"
97 regex = '\w+'
98 haystack = "aδ"
99 matches = [[0, 1]]
100 unicode = false
101
102 [[test]]
103 name = "word-unicode"
104 regex = '\w+'
105 haystack = "aδ"
106 matches = [[0, 3]]
107
108 [[test]]
109 name = "decimal-ascii"
110 regex = '\d+'
111 haystack = "1२३9"
112 matches = [[0, 1], [7, 8]]
113 unicode = false
114
115 [[test]]
116 name = "decimal-unicode"
117 regex = '\d+'
118 haystack = "1२३9"
119 matches = [[0, 8]]
120
121 [[test]]
122 name = "space-ascii"
123 regex = '\s+'
124 haystack = " \u1680"
125 matches = [[0, 1]]
126 unicode = false
127
128 [[test]]
129 name = "space-unicode"
130 regex = '\s+'
131 haystack = " \u1680"
132 matches = [[0, 4]]
133
134
135 [[test]]
136 # See: https://github.com/rust-lang/regex/issues/484
137 name = "iter1-bytes"
138 regex = ''
139 haystack = "☃"
140 matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
141 utf8 = false
142
143 [[test]]
144 # See: https://github.com/rust-lang/regex/issues/484
145 name = "iter1-utf8"
146 regex = ''
147 haystack = "☃"
148 matches = [[0, 0], [3, 3]]
149
150 [[test]]
151 # See: https://github.com/rust-lang/regex/issues/484
152 # Note that iter2-utf8 doesn't make sense here, since the input isn't UTF-8.
153 name = "iter2-bytes"
154 regex = ''
155 haystack = 'b\xFFr'
156 matches = [[0, 0], [1, 1], [2, 2], [3, 3]]
157 unescape = true
158 utf8 = false
159
160
161 # These test that unanchored prefixes can munch through invalid UTF-8 even when
162 # utf8 is enabled.
163 #
164 # This test actually reflects an interesting simplification in how the Thompson
165 # NFA is constructed. It used to be that the NFA could be built with an
166 # unanchored prefix that either matched any byte or _only_ matched valid UTF-8.
167 # But the latter turns out to be pretty precarious when it comes to prefilters,
168 # because if you search a haystack that contains invalid UTF-8 but have an
169 # unanchored prefix that requires UTF-8, then prefilters are no longer a valid
170 # optimization because you actually have to check that everything is valid
171 # UTF-8.
172 #
173 # Originally, I had thought that we needed a valid UTF-8 unanchored prefix in
174 # order to guarantee that we only match at valid UTF-8 boundaries. But this
175 # isn't actually true! There are really only two things to consider here:
176 #
177 # 1) Will a regex match split an encoded codepoint? No. Because by construction,
178 # we ensure that a MATCH state can only be reached by following valid UTF-8 (assuming
179 # all of the UTF-8 modes are enabled).
180 #
181 # 2) Will a regex match arbitrary bytes that aren't valid UTF-8? Again, no,
182 # assuming all of the UTF-8 modes are enabled.
183 [[test]]
184 name = "unanchored-invalid-utf8-match-100"
185 regex = '[a-z]'
186 haystack = '\xFFa\xFF'
187 matches = [[1, 2]]
188 unescape = true
189 utf8 = false
190
191 # This test shows that we can still prevent a match from occurring by requiring
192 # that valid UTF-8 match by inserting our own unanchored prefix. Thus, if the
193 # behavior of not munching through invalid UTF-8 anywhere is needed, then it
194 # can be achieved thusly.
195 [[test]]
196 name = "unanchored-invalid-utf8-nomatch"
197 regex = '^(?s:.)*?[a-z]'
198 haystack = '\xFFa\xFF'
199 matches = []
200 unescape = true
201 utf8 = false
202
203 # This is a tricky test that makes sure we don't accidentally do a kind of
204 # unanchored search when we've requested that a regex engine not report
205 # empty matches that split a codepoint. This test caught a regression during
206 # development where the code for skipping over bad empty matches would do so
207 # even if the search should have been anchored. This is ultimately what led to
208 # making 'anchored' an 'Input' option, so that it was always clear what kind
209 # of search was being performed. (Before that, whether a search was anchored
210 # or not was a config knob on the regex engine.) This did wind up making DFAs
211 # a little more complex to configure (with their 'StartKind' knob), but it
212 # generally smoothed out everything else.
213 #
214 # Great example of a test whose failure motivated a sweeping API refactoring.
215 [[test]]
216 name = "anchored-iter-empty-utf8"
217 regex = ''
218 haystack = 'a☃z'
219 matches = [[0, 0], [1, 1]]
220 unescape = false
221 utf8 = true
222 anchored = true