1 // Many of these are cribbed from RE2's test suite.
2 
3 matiter!(wb1, r"\b", "");
4 matiter!(wb2, r"\b", "a", (0, 0), (1, 1));
5 matiter!(wb3, r"\b", "ab", (0, 0), (2, 2));
6 matiter!(wb4, r"^\b", "ab", (0, 0));
7 matiter!(wb5, r"\b$", "ab", (2, 2));
8 matiter!(wb6, r"^\b$", "ab");
9 matiter!(wb7, r"\bbar\b", "nobar bar foo bar", (6, 9), (14, 17));
10 matiter!(wb8, r"a\b", "faoa x", (3, 4));
11 matiter!(wb9, r"\bbar", "bar x", (0, 3));
12 matiter!(wb10, r"\bbar", "foo\nbar x", (4, 7));
13 matiter!(wb11, r"bar\b", "foobar", (3, 6));
14 matiter!(wb12, r"bar\b", "foobar\nxxx", (3, 6));
15 matiter!(wb13, r"(foo|bar|[A-Z])\b", "foo", (0, 3));
16 matiter!(wb14, r"(foo|bar|[A-Z])\b", "foo\n", (0, 3));
17 matiter!(wb15, r"\b(foo|bar|[A-Z])", "foo", (0, 3));
18 matiter!(wb16, r"\b(foo|bar|[A-Z])\b", "X", (0, 1));
19 matiter!(wb17, r"\b(foo|bar|[A-Z])\b", "XY");
20 matiter!(wb18, r"\b(foo|bar|[A-Z])\b", "bar", (0, 3));
21 matiter!(wb19, r"\b(foo|bar|[A-Z])\b", "foo", (0, 3));
22 matiter!(wb20, r"\b(foo|bar|[A-Z])\b", "foo\n", (0, 3));
23 matiter!(wb21, r"\b(foo|bar|[A-Z])\b", "ffoo bbar N x", (10, 11));
24 matiter!(wb22, r"\b(fo|foo)\b", "fo", (0, 2));
25 matiter!(wb23, r"\b(fo|foo)\b", "foo", (0, 3));
26 matiter!(wb24, r"\b\b", "");
27 matiter!(wb25, r"\b\b", "a", (0, 0), (1, 1));
28 matiter!(wb26, r"\b$", "");
29 matiter!(wb27, r"\b$", "x", (1, 1));
30 matiter!(wb28, r"\b$", "y x", (3, 3));
31 matiter!(wb29, r"\b.$", "x", (0, 1));
32 matiter!(wb30, r"^\b(fo|foo)\b", "fo", (0, 2));
33 matiter!(wb31, r"^\b(fo|foo)\b", "foo", (0, 3));
34 matiter!(wb32, r"^\b$", "");
35 matiter!(wb33, r"^\b$", "x");
36 matiter!(wb34, r"^\b.$", "x", (0, 1));
37 matiter!(wb35, r"^\b.\b$", "x", (0, 1));
38 matiter!(wb36, r"^^^^^\b$$$$$", "");
39 matiter!(wb37, r"^^^^^\b.$$$$$", "x", (0, 1));
40 matiter!(wb38, r"^^^^^\b$$$$$", "x");
41 matiter!(wb39, r"^^^^^\b\b\b.\b\b\b$$$$$", "x", (0, 1));
42 matiter!(wb40, r"\b.+\b", "$$abc$$", (2, 5));
43 matiter!(wb41, r"\b", "a b c", (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5));
44 
45 matiter!(nb1, r"\Bfoo\B", "n foo xfoox that", (7, 10));
46 matiter!(nb2, r"a\B", "faoa x", (1, 2));
47 matiter!(nb3, r"\Bbar", "bar x");
48 matiter!(nb4, r"\Bbar", "foo\nbar x");
49 matiter!(nb5, r"bar\B", "foobar");
50 matiter!(nb6, r"bar\B", "foobar\nxxx");
51 matiter!(nb7, r"(foo|bar|[A-Z])\B", "foox", (0, 3));
52 matiter!(nb8, r"(foo|bar|[A-Z])\B", "foo\n");
53 matiter!(nb9, r"\B", "", (0, 0));
54 matiter!(nb10, r"\B", "x");
55 matiter!(nb11, r"\B(foo|bar|[A-Z])", "foo");
56 matiter!(nb12, r"\B(foo|bar|[A-Z])\B", "xXy", (1, 2));
57 matiter!(nb13, r"\B(foo|bar|[A-Z])\B", "XY");
58 matiter!(nb14, r"\B(foo|bar|[A-Z])\B", "XYZ", (1, 2));
59 matiter!(nb15, r"\B(foo|bar|[A-Z])\B", "abara", (1, 4));
60 matiter!(nb16, r"\B(foo|bar|[A-Z])\B", "xfoo_", (1, 4));
61 matiter!(nb17, r"\B(foo|bar|[A-Z])\B", "xfoo\n");
62 matiter!(nb18, r"\B(foo|bar|[A-Z])\B", "foo bar vNX", (9, 10));
63 matiter!(nb19, r"\B(fo|foo)\B", "xfoo", (1, 3));
64 matiter!(nb20, r"\B(foo|fo)\B", "xfooo", (1, 4));
65 matiter!(nb21, r"\B\B", "", (0, 0));
66 matiter!(nb22, r"\B\B", "x");
67 matiter!(nb23, r"\B$", "", (0, 0));
68 matiter!(nb24, r"\B$", "x");
69 matiter!(nb25, r"\B$", "y x");
70 matiter!(nb26, r"\B.$", "x");
71 matiter!(nb27, r"^\B(fo|foo)\B", "fo");
72 matiter!(nb28, r"^\B(fo|foo)\B", "foo");
73 matiter!(nb29, r"^\B", "", (0, 0));
74 matiter!(nb30, r"^\B", "x");
75 matiter!(nb31, r"^\B\B", "", (0, 0));
76 matiter!(nb32, r"^\B\B", "x");
77 matiter!(nb33, r"^\B$", "", (0, 0));
78 matiter!(nb34, r"^\B$", "x");
79 matiter!(nb35, r"^\B.$", "x");
80 matiter!(nb36, r"^\B.\B$", "x");
81 matiter!(nb37, r"^^^^^\B$$$$$", "", (0, 0));
82 matiter!(nb38, r"^^^^^\B.$$$$$", "x");
83 matiter!(nb39, r"^^^^^\B$$$$$", "x");
84 
85 // These work for both Unicode and ASCII because all matches are reported as
86 // byte offsets, and « and » do not correspond to word boundaries at either
87 // the character or byte level.
88 matiter!(unicode1, r"\bx\b", "«x", (2, 3));
89 matiter!(unicode2, r"\bx\b", "x»", (0, 1));
90