Debian Codegraph @

.cargo/vendor/regex/testdata/word-boundary.toml

raw
1 # Some of these are cribbed from RE2's test suite.
2
3 # These test \b. Below are tests for \B.
4 [[test]]
5 name = "wb1"
6 regex = '\b'
7 haystack = ""
8 matches = []
9 unicode = false
10
11 [[test]]
12 name = "wb2"
13 regex = '\b'
14 haystack = "a"
15 matches = [[0, 0], [1, 1]]
16 unicode = false
17
18 [[test]]
19 name = "wb3"
20 regex = '\b'
21 haystack = "ab"
22 matches = [[0, 0], [2, 2]]
23 unicode = false
24
25 [[test]]
26 name = "wb4"
27 regex = '^\b'
28 haystack = "ab"
29 matches = [[0, 0]]
30 unicode = false
31
32 [[test]]
33 name = "wb5"
34 regex = '\b$'
35 haystack = "ab"
36 matches = [[2, 2]]
37 unicode = false
38
39 [[test]]
40 name = "wb6"
41 regex = '^\b$'
42 haystack = "ab"
43 matches = []
44 unicode = false
45
46 [[test]]
47 name = "wb7"
48 regex = '\bbar\b'
49 haystack = "nobar bar foo bar"
50 matches = [[6, 9], [14, 17]]
51 unicode = false
52
53 [[test]]
54 name = "wb8"
55 regex = 'a\b'
56 haystack = "faoa x"
57 matches = [[3, 4]]
58 unicode = false
59
60 [[test]]
61 name = "wb9"
62 regex = '\bbar'
63 haystack = "bar x"
64 matches = [[0, 3]]
65 unicode = false
66
67 [[test]]
68 name = "wb10"
69 regex = '\bbar'
70 haystack = "foo\nbar x"
71 matches = [[4, 7]]
72 unicode = false
73
74 [[test]]
75 name = "wb11"
76 regex = 'bar\b'
77 haystack = "foobar"
78 matches = [[3, 6]]
79 unicode = false
80
81 [[test]]
82 name = "wb12"
83 regex = 'bar\b'
84 haystack = "foobar\nxxx"
85 matches = [[3, 6]]
86 unicode = false
87
88 [[test]]
89 name = "wb13"
90 regex = '(?:foo|bar|[A-Z])\b'
91 haystack = "foo"
92 matches = [[0, 3]]
93 unicode = false
94
95 [[test]]
96 name = "wb14"
97 regex = '(?:foo|bar|[A-Z])\b'
98 haystack = "foo\n"
99 matches = [[0, 3]]
100 unicode = false
101
102 [[test]]
103 name = "wb15"
104 regex = '\b(?:foo|bar|[A-Z])'
105 haystack = "foo"
106 matches = [[0, 3]]
107 unicode = false
108
109 [[test]]
110 name = "wb16"
111 regex = '\b(?:foo|bar|[A-Z])\b'
112 haystack = "X"
113 matches = [[0, 1]]
114 unicode = false
115
116 [[test]]
117 name = "wb17"
118 regex = '\b(?:foo|bar|[A-Z])\b'
119 haystack = "XY"
120 matches = []
121 unicode = false
122
123 [[test]]
124 name = "wb18"
125 regex = '\b(?:foo|bar|[A-Z])\b'
126 haystack = "bar"
127 matches = [[0, 3]]
128 unicode = false
129
130 [[test]]
131 name = "wb19"
132 regex = '\b(?:foo|bar|[A-Z])\b'
133 haystack = "foo"
134 matches = [[0, 3]]
135 unicode = false
136
137 [[test]]
138 name = "wb20"
139 regex = '\b(?:foo|bar|[A-Z])\b'
140 haystack = "foo\n"
141 matches = [[0, 3]]
142 unicode = false
143
144 [[test]]
145 name = "wb21"
146 regex = '\b(?:foo|bar|[A-Z])\b'
147 haystack = "ffoo bbar N x"
148 matches = [[10, 11]]
149 unicode = false
150
151 [[test]]
152 name = "wb22"
153 regex = '\b(?:fo|foo)\b'
154 haystack = "fo"
155 matches = [[0, 2]]
156 unicode = false
157
158 [[test]]
159 name = "wb23"
160 regex = '\b(?:fo|foo)\b'
161 haystack = "foo"
162 matches = [[0, 3]]
163 unicode = false
164
165 [[test]]
166 name = "wb24"
167 regex = '\b\b'
168 haystack = ""
169 matches = []
170 unicode = false
171
172 [[test]]
173 name = "wb25"
174 regex = '\b\b'
175 haystack = "a"
176 matches = [[0, 0], [1, 1]]
177 unicode = false
178
179 [[test]]
180 name = "wb26"
181 regex = '\b$'
182 haystack = ""
183 matches = []
184 unicode = false
185
186 [[test]]
187 name = "wb27"
188 regex = '\b$'
189 haystack = "x"
190 matches = [[1, 1]]
191 unicode = false
192
193 [[test]]
194 name = "wb28"
195 regex = '\b$'
196 haystack = "y x"
197 matches = [[3, 3]]
198 unicode = false
199
200 [[test]]
201 name = "wb29"
202 regex = '(?-u:\b).$'
203 haystack = "x"
204 matches = [[0, 1]]
205
206 [[test]]
207 name = "wb30"
208 regex = '^\b(?:fo|foo)\b'
209 haystack = "fo"
210 matches = [[0, 2]]
211 unicode = false
212
213 [[test]]
214 name = "wb31"
215 regex = '^\b(?:fo|foo)\b'
216 haystack = "foo"
217 matches = [[0, 3]]
218 unicode = false
219
220 [[test]]
221 name = "wb32"
222 regex = '^\b$'
223 haystack = ""
224 matches = []
225 unicode = false
226
227 [[test]]
228 name = "wb33"
229 regex = '^\b$'
230 haystack = "x"
231 matches = []
232 unicode = false
233
234 [[test]]
235 name = "wb34"
236 regex = '^(?-u:\b).$'
237 haystack = "x"
238 matches = [[0, 1]]
239
240 [[test]]
241 name = "wb35"
242 regex = '^(?-u:\b).(?-u:\b)$'
243 haystack = "x"
244 matches = [[0, 1]]
245
246 [[test]]
247 name = "wb36"
248 regex = '^^^^^\b$$$$$'
249 haystack = ""
250 matches = []
251 unicode = false
252
253 [[test]]
254 name = "wb37"
255 regex = '^^^^^(?-u:\b).$$$$$'
256 haystack = "x"
257 matches = [[0, 1]]
258
259 [[test]]
260 name = "wb38"
261 regex = '^^^^^\b$$$$$'
262 haystack = "x"
263 matches = []
264 unicode = false
265
266 [[test]]
267 name = "wb39"
268 regex = '^^^^^(?-u:\b\b\b).(?-u:\b\b\b)$$$$$'
269 haystack = "x"
270 matches = [[0, 1]]
271
272 [[test]]
273 name = "wb40"
274 regex = '(?-u:\b).+(?-u:\b)'
275 haystack = "$$abc$$"
276 matches = [[2, 5]]
277
278 [[test]]
279 name = "wb41"
280 regex = '\b'
281 haystack = "a b c"
282 matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]
283 unicode = false
284
285 [[test]]
286 name = "wb42"
287 regex = '\bfoo\b'
288 haystack = "zzz foo zzz"
289 matches = [[4, 7]]
290 unicode = false
291
292 [[test]]
293 name = "wb43"
294 regex = '\b^'
295 haystack = "ab"
296 matches = [[0, 0]]
297 unicode = false
298
299 [[test]]
300 name = "wb44"
301 regex = '$\b'
302 haystack = "ab"
303 matches = [[2, 2]]
304 unicode = false
305
306
307 # Tests for \B. Note that \B is not allowed if UTF-8 mode is enabled, so we
308 # have to disable it for most of these tests. This is because \B can match at
309 # non-UTF-8 boundaries.
310 [[test]]
311 name = "nb1"
312 regex = '\Bfoo\B'
313 haystack = "n foo xfoox that"
314 matches = [[7, 10]]
315 unicode = false
316 utf8 = false
317
318 [[test]]
319 name = "nb2"
320 regex = 'a\B'
321 haystack = "faoa x"
322 matches = [[1, 2]]
323 unicode = false
324 utf8 = false
325
326 [[test]]
327 name = "nb3"
328 regex = '\Bbar'
329 haystack = "bar x"
330 matches = []
331 unicode = false
332 utf8 = false
333
334 [[test]]
335 name = "nb4"
336 regex = '\Bbar'
337 haystack = "foo\nbar x"
338 matches = []
339 unicode = false
340 utf8 = false
341
342 [[test]]
343 name = "nb5"
344 regex = 'bar\B'
345 haystack = "foobar"
346 matches = []
347 unicode = false
348 utf8 = false
349
350 [[test]]
351 name = "nb6"
352 regex = 'bar\B'
353 haystack = "foobar\nxxx"
354 matches = []
355 unicode = false
356 utf8 = false
357
358 [[test]]
359 name = "nb7"
360 regex = '(?:foo|bar|[A-Z])\B'
361 haystack = "foox"
362 matches = [[0, 3]]
363 unicode = false
364 utf8 = false
365
366 [[test]]
367 name = "nb8"
368 regex = '(?:foo|bar|[A-Z])\B'
369 haystack = "foo\n"
370 matches = []
371 unicode = false
372 utf8 = false
373
374 [[test]]
375 name = "nb9"
376 regex = '\B'
377 haystack = ""
378 matches = [[0, 0]]
379 unicode = false
380 utf8 = false
381
382 [[test]]
383 name = "nb10"
384 regex = '\B'
385 haystack = "x"
386 matches = []
387 unicode = false
388 utf8 = false
389
390 [[test]]
391 name = "nb11"
392 regex = '\B(?:foo|bar|[A-Z])'
393 haystack = "foo"
394 matches = []
395 unicode = false
396 utf8 = false
397
398 [[test]]
399 name = "nb12"
400 regex = '\B(?:foo|bar|[A-Z])\B'
401 haystack = "xXy"
402 matches = [[1, 2]]
403 unicode = false
404 utf8 = false
405
406 [[test]]
407 name = "nb13"
408 regex = '\B(?:foo|bar|[A-Z])\B'
409 haystack = "XY"
410 matches = []
411 unicode = false
412 utf8 = false
413
414 [[test]]
415 name = "nb14"
416 regex = '\B(?:foo|bar|[A-Z])\B'
417 haystack = "XYZ"
418 matches = [[1, 2]]
419 unicode = false
420 utf8 = false
421
422 [[test]]
423 name = "nb15"
424 regex = '\B(?:foo|bar|[A-Z])\B'
425 haystack = "abara"
426 matches = [[1, 4]]
427 unicode = false
428 utf8 = false
429
430 [[test]]
431 name = "nb16"
432 regex = '\B(?:foo|bar|[A-Z])\B'
433 haystack = "xfoo_"
434 matches = [[1, 4]]
435 unicode = false
436 utf8 = false
437
438 [[test]]
439 name = "nb17"
440 regex = '\B(?:foo|bar|[A-Z])\B'
441 haystack = "xfoo\n"
442 matches = []
443 unicode = false
444 utf8 = false
445
446 [[test]]
447 name = "nb18"
448 regex = '\B(?:foo|bar|[A-Z])\B'
449 haystack = "foo bar vNX"
450 matches = [[9, 10]]
451 unicode = false
452 utf8 = false
453
454 [[test]]
455 name = "nb19"
456 regex = '\B(?:fo|foo)\B'
457 haystack = "xfoo"
458 matches = [[1, 3]]
459 unicode = false
460 utf8 = false
461
462 [[test]]
463 name = "nb20"
464 regex = '\B(?:foo|fo)\B'
465 haystack = "xfooo"
466 matches = [[1, 4]]
467 unicode = false
468 utf8 = false
469
470 [[test]]
471 name = "nb21"
472 regex = '\B\B'
473 haystack = ""
474 matches = [[0, 0]]
475 unicode = false
476 utf8 = false
477
478 [[test]]
479 name = "nb22"
480 regex = '\B\B'
481 haystack = "x"
482 matches = []
483 unicode = false
484 utf8 = false
485
486 [[test]]
487 name = "nb23"
488 regex = '\B$'
489 haystack = ""
490 matches = [[0, 0]]
491 unicode = false
492 utf8 = false
493
494 [[test]]
495 name = "nb24"
496 regex = '\B$'
497 haystack = "x"
498 matches = []
499 unicode = false
500 utf8 = false
501
502 [[test]]
503 name = "nb25"
504 regex = '\B$'
505 haystack = "y x"
506 matches = []
507 unicode = false
508 utf8 = false
509
510 [[test]]
511 name = "nb26"
512 regex = '\B.$'
513 haystack = "x"
514 matches = []
515 unicode = false
516 utf8 = false
517
518 [[test]]
519 name = "nb27"
520 regex = '^\B(?:fo|foo)\B'
521 haystack = "fo"
522 matches = []
523 unicode = false
524 utf8 = false
525
526 [[test]]
527 name = "nb28"
528 regex = '^\B(?:fo|foo)\B'
529 haystack = "fo"
530 matches = []
531 unicode = false
532 utf8 = false
533
534 [[test]]
535 name = "nb29"
536 regex = '^\B'
537 haystack = ""
538 matches = [[0, 0]]
539 unicode = false
540 utf8 = false
541
542 [[test]]
543 name = "nb30"
544 regex = '^\B'
545 haystack = "x"
546 matches = []
547 unicode = false
548 utf8 = false
549
550 [[test]]
551 name = "nb31"
552 regex = '^\B\B'
553 haystack = ""
554 matches = [[0, 0]]
555 unicode = false
556 utf8 = false
557
558 [[test]]
559 name = "nb32"
560 regex = '^\B\B'
561 haystack = "x"
562 matches = []
563 unicode = false
564 utf8 = false
565
566 [[test]]
567 name = "nb33"
568 regex = '^\B$'
569 haystack = ""
570 matches = [[0, 0]]
571 unicode = false
572 utf8 = false
573
574 [[test]]
575 name = "nb34"
576 regex = '^\B$'
577 haystack = "x"
578 matches = []
579 unicode = false
580 utf8 = false
581
582 [[test]]
583 name = "nb35"
584 regex = '^\B.$'
585 haystack = "x"
586 matches = []
587 unicode = false
588 utf8 = false
589
590 [[test]]
591 name = "nb36"
592 regex = '^\B.\B$'
593 haystack = "x"
594 matches = []
595 unicode = false
596 utf8 = false
597
598 [[test]]
599 name = "nb37"
600 regex = '^^^^^\B$$$$$'
601 haystack = ""
602 matches = [[0, 0]]
603 unicode = false
604 utf8 = false
605
606 [[test]]
607 name = "nb38"
608 regex = '^^^^^\B.$$$$$'
609 haystack = "x"
610 matches = []
611 unicode = false
612 utf8 = false
613
614 [[test]]
615 name = "nb39"
616 regex = '^^^^^\B$$$$$'
617 haystack = "x"
618 matches = []
619 unicode = false
620 utf8 = false
621
622
623 # unicode1* and unicode2* work for both Unicode and ASCII because all matches
624 # are reported as byte offsets, and « and » do not correspond to word
625 # boundaries at either the character or byte level.
626 [[test]]
627 name = "unicode1"
628 regex = '\bx\b'
629 haystack = "«x"
630 matches = [[2, 3]]
631
632 [[test]]
633 name = "unicode1-only-ascii"
634 regex = '\bx\b'
635 haystack = "«x"
636 matches = [[2, 3]]
637 unicode = false
638
639 [[test]]
640 name = "unicode2"
641 regex = '\bx\b'
642 haystack = "x»"
643 matches = [[0, 1]]
644
645 [[test]]
646 name = "unicode2-only-ascii"
647 regex = '\bx\b'
648 haystack = "x»"
649 matches = [[0, 1]]
650 unicode = false
651
652 # ASCII word boundaries are completely oblivious to Unicode characters, so
653 # even though β is a character, an ASCII \b treats it as a word boundary
654 # when it is adjacent to another ASCII character. (The ASCII \b only looks
655 # at the leading byte of β.) For Unicode \b, the tests are precisely inverted.
656 [[test]]
657 name = "unicode3"
658 regex = '\bx\b'
659 haystack = 'áxβ'
660 matches = []
661
662 [[test]]
663 name = "unicode3-only-ascii"
664 regex = '\bx\b'
665 haystack = 'áxβ'
666 matches = [[2, 3]]
667 unicode = false
668
669 [[test]]
670 name = "unicode4"
671 regex = '\Bx\B'
672 haystack = 'áxβ'
673 matches = [[2, 3]]
674
675 [[test]]
676 name = "unicode4-only-ascii"
677 regex = '\Bx\B'
678 haystack = 'áxβ'
679 matches = []
680 unicode = false
681 utf8 = false
682
683 # The same as above, but with \b instead of \B as a sanity check.
684 [[test]]
685 name = "unicode5"
686 regex = '\b'
687 haystack = "0\U0007EF5E"
688 matches = [[0, 0], [1, 1]]
689
690 [[test]]
691 name = "unicode5-only-ascii"
692 regex = '\b'
693 haystack = "0\U0007EF5E"
694 matches = [[0, 0], [1, 1]]
695 unicode = false
696 utf8 = false
697
698 [[test]]
699 name = "unicode5-noutf8"
700 regex = '\b'
701 haystack = '0\xFF\xFF\xFF\xFF'
702 matches = [[0, 0], [1, 1]]
703 unescape = true
704 utf8 = false
705
706 [[test]]
707 name = "unicode5-noutf8-only-ascii"
708 regex = '\b'
709 haystack = '0\xFF\xFF\xFF\xFF'
710 matches = [[0, 0], [1, 1]]
711 unescape = true
712 unicode = false
713 utf8 = false
714
715 # Weird special case to ensure that ASCII \B treats each individual code unit
716 # as a non-word byte. (The specific codepoint is irrelevant. It's an arbitrary
717 # codepoint that uses 4 bytes in its UTF-8 encoding and is not a member of the
718 # \w character class.)
719 [[test]]
720 name = "unicode5-not"
721 regex = '\B'
722 haystack = "0\U0007EF5E"
723 matches = [[5, 5]]
724
725 [[test]]
726 name = "unicode5-not-only-ascii"
727 regex = '\B'
728 haystack = "0\U0007EF5E"
729 matches = [[2, 2], [3, 3], [4, 4], [5, 5]]
730 unicode = false
731 utf8 = false
732
733 # This gets no matches since \B only matches in the presence of valid UTF-8
734 # when Unicode is enabled, even when UTF-8 mode is disabled.
735 [[test]]
736 name = "unicode5-not-noutf8"
737 regex = '\B'
738 haystack = '0\xFF\xFF\xFF\xFF'
739 matches = []
740 unescape = true
741 utf8 = false
742
743 # But this DOES get matches since \B in ASCII mode only looks at individual
744 # bytes.
745 [[test]]
746 name = "unicode5-not-noutf8-only-ascii"
747 regex = '\B'
748 haystack = '0\xFF\xFF\xFF\xFF'
749 matches = [[2, 2], [3, 3], [4, 4], [5, 5]]
750 unescape = true
751 unicode = false
752 utf8 = false
753
754 # Some tests of no particular significance.
755 [[test]]
756 name = "unicode6"
757 regex = '\b[0-9]+\b'
758 haystack = "foo 123 bar 456 quux 789"
759 matches = [[4, 7], [12, 15], [21, 24]]
760
761 [[test]]
762 name = "unicode7"
763 regex = '\b[0-9]+\b'
764 haystack = "foo 123 bar a456 quux 789"
765 matches = [[4, 7], [22, 25]]
766
767 [[test]]
768 name = "unicode8"
769 regex = '\b[0-9]+\b'
770 haystack = "foo 123 bar 456a quux 789"
771 matches = [[4, 7], [22, 25]]
772
773 # A variant of the problem described here:
774 # https://github.com/google/re2/blob/89567f5de5b23bb5ad0c26cbafc10bdc7389d1fa/re2/dfa.cc#L658-L667
775 [[test]]
776 name = "alt-with-assertion-repetition"
777 regex = '(?:\b|%)+'
778 haystack = "z%"
779 bounds = [1, 2]
780 anchored = true
781 matches = [[1, 1]]