MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tests_include.h
1 const char *test_array[] =
2 {
3  "# regular expression test set",
4  "# Lines are at least three fields, separated by one or more tabs. \"\" stands",
5  "# for an empty field. First field is an RE. Second field is flags. If",
6  "# C flag given, regcomp() is expected to fail, and the third field is the",
7  "# error name (minus the leading REG_).",
8  "#",
9  "# Otherwise it is expected to succeed, and the third field is the string to",
10  "# try matching it against. If there is no fourth field, the match is",
11  "# expected to fail. If there is a fourth field, it is the substring that",
12  "# the RE is expected to match. If there is a fifth field, it is a comma-",
13  "# separated list of what the subexpressions should match, with - indicating",
14  "# no match for that one. In both the fourth and fifth fields, a (sub)field",
15  "# starting with @ indicates that the (sub)expression is expected to match",
16  "# a null string followed by the stuff after the @; this provides a way to",
17  "# test where null strings match. The character `N' in REs and strings",
18  "# is newline, `S' is space, `T' is tab, `Z' is NUL.",
19  "#",
20  "# The full list of flags:",
21  "# - placeholder, does nothing",
22  "# b RE is a BRE, not an ERE",
23  "# & try it as both an ERE and a BRE",
24  "# C regcomp() error expected, third field is error name",
25  "# i REG_ICASE",
26  "# m (\"mundane\") REG_NOSPEC",
27  "# s REG_NOSUB (not really testable)",
28  "# n REG_NEWLINE",
29  "# ^ REG_NOTBOL",
30  "# $ REG_NOTEOL",
31  "# # REG_STARTEND (see below)",
32  "# p REG_PEND",
33  "#",
34  "# For REG_STARTEND, the start/end offsets are those of the substring",
35  "# enclosed in ().",
36  "",
37  "# basics",
38  "a & a a",
39  "abc & abc abc",
40  "abc|de - abc abc",
41  "a|b|c - abc a",
42  "",
43  "# parentheses and perversions thereof",
44  "a(b)c - abc abc",
45  "a\\(b\\)c b abc abc",
46  "a( C EPAREN",
47  "a( b a( a(",
48  "a\\( - a( a(",
49  "a\\( bC EPAREN",
50  "a\\(b bC EPAREN",
51  "a(b C EPAREN",
52  "a(b b a(b a(b",
53  "# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)",
54  "a) - a) a)",
55  ") - ) )",
56  "# end gagging (in a just world, those *should* give EPAREN)",
57  "a) b a) a)",
58  "a\\) bC EPAREN",
59  "\\) bC EPAREN",
60  "a()b - ab ab",
61  "a\\(\\)b b ab ab",
62  "",
63  "# anchoring and REG_NEWLINE",
64  "^abc$ & abc abc",
65  "a^b - a^b",
66  "a^b b a^b a^b",
67  "a$b - a$b",
68  "a$b b a$b a$b",
69  "^ & abc @abc",
70  "$ & abc @",
71  "^$ & \"\" @",
72  "$^ - \"\" @",
73  "\\($\\)\\(^\\) b \"\" @",
74  "# stop retching, those are legitimate (although disgusting)",
75  "^^ - \"\" @",
76  "$$ - \"\" @",
77  "b$ & abNc",
78  "b$ &n abNc b",
79  "^b$ & aNbNc",
80  "^b$ &n aNbNc b",
81  "^$ &n aNNb @Nb",
82  "^$ n abc",
83  "^$ n abcN @",
84  "$^ n aNNb @Nb",
85  "\\($\\)\\(^\\) bn aNNb @Nb",
86  "^^ n^ aNNb @Nb",
87  "$$ n aNNb @NN",
88  "^a ^ a",
89  "a$ $ a",
90  "^a ^n aNb",
91  "^b ^n aNb b",
92  "a$ $n bNa",
93  "b$ $n bNa b",
94  "a*(^b$)c* - b b",
95  "a*\\(^b$\\)c* b b b",
96  "",
97  "# certain syntax errors and non-errors",
98  "| C EMPTY",
99  "| b | |",
100  "* C BADRPT",
101  "* b * *",
102  "+ C BADRPT",
103  "? C BADRPT",
104  "\"\" &C EMPTY",
105  "() - abc @abc",
106  "\\(\\) b abc @abc",
107  "a||b C EMPTY",
108  "|ab C EMPTY",
109  "ab| C EMPTY",
110  "(|a)b C EMPTY",
111  "(a|)b C EMPTY",
112  "(*a) C BADRPT",
113  "(+a) C BADRPT",
114  "(?a) C BADRPT",
115  "({1}a) C BADRPT",
116  "\\(\\{1\\}a\\) bC BADRPT",
117  "(a|*b) C BADRPT",
118  "(a|+b) C BADRPT",
119  "(a|?b) C BADRPT",
120  "(a|{1}b) C BADRPT",
121  "^* C BADRPT",
122  "^* b * *",
123  "^+ C BADRPT",
124  "^? C BADRPT",
125  "^{1} C BADRPT",
126  "^\\{1\\} bC BADRPT",
127  "",
128  "# metacharacters, backslashes",
129  "a.c & abc abc",
130  "a[bc]d & abd abd",
131  "a\\*c & a*c a*c",
132  "a\\\\b & a\\b a\\b",
133  "a\\\\\\*b & a\\*b a\\*b",
134  "a\\bc & abc abc",
135  "a\\ &C EESCAPE",
136  "a\\\\bc & a\\bc a\\bc",
137  "\\{ bC BADRPT",
138  "a\\[b & a[b a[b",
139  "a[b &C EBRACK",
140  "# trailing $ is a peculiar special case for the BRE code",
141  "a$ & a a",
142  "a$ & a$",
143  "a\\$ & a",
144  "a\\$ & a$ a$",
145  "a\\\\$ & a",
146  "a\\\\$ & a$",
147  "a\\\\$ & a\\$",
148  "a\\\\$ & a\\ a\\",
149  "",
150  "# back references, ugh",
151  "a\\(b\\)\\2c bC ESUBREG",
152  "a\\(b\\1\\)c bC ESUBREG",
153  "a\\(b*\\)c\\1d b abbcbbd abbcbbd bb",
154  "a\\(b*\\)c\\1d b abbcbd",
155  "a\\(b*\\)c\\1d b abbcbbbd",
156  "^\\(.\\)\\1 b abc",
157  "a\\([bc]\\)\\1d b abcdabbd abbd b",
158  "a\\(\\([bc]\\)\\2\\)*d b abbccd abbccd",
159  "a\\(\\([bc]\\)\\2\\)*d b abbcbd",
160  "# actually, this next one probably ought to fail, but the spec is unclear",
161  "a\\(\\(b\\)*\\2\\)*d b abbbd abbbd",
162  "# here is a case that no NFA implementation does right",
163  "\\(ab*\\)[ab]*\\1 b ababaaa ababaaa a",
164  "# check out normal matching in the presence of back refs",
165  "\\(a\\)\\1bcd b aabcd aabcd",
166  "\\(a\\)\\1bc*d b aabcd aabcd",
167  "\\(a\\)\\1bc*d b aabd aabd",
168  "\\(a\\)\\1bc*d b aabcccd aabcccd",
169  "\\(a\\)\\1bc*[ce]d b aabcccd aabcccd",
170  "^\\(a\\)\\1b\\(c\\)*cd$ b aabcccd aabcccd",
171  "",
172  "# ordinary repetitions",
173  "ab*c & abc abc",
174  "ab+c - abc abc",
175  "ab?c - abc abc",
176  "a\\(*\\)b b a*b a*b",
177  "a\\(**\\)b b ab ab",
178  "a\\(***\\)b bC BADRPT",
179  "*a b *a *a",
180  "**a b a a",
181  "***a bC BADRPT",
182  "",
183  "# the dreaded bounded repetitions",
184  "{ & { {",
185  "{abc & {abc {abc",
186  "{1 C BADRPT",
187  "{1} C BADRPT",
188  "a{b & a{b a{b",
189  "a{1}b - ab ab",
190  "a\\{1\\}b b ab ab",
191  "a{1,}b - ab ab",
192  "a\\{1,\\}b b ab ab",
193  "a{1,2}b - aab aab",
194  "a\\{1,2\\}b b aab aab",
195  "a{1 C EBRACE",
196  "a\\{1 bC EBRACE",
197  "a{1a C EBRACE",
198  "a\\{1a bC EBRACE",
199  "a{1a} C BADBR",
200  "a\\{1a\\} bC BADBR",
201  "a{,2} - a{,2} a{,2}",
202  "a\\{,2\\} bC BADBR",
203  "a{,} - a{,} a{,}",
204  "a\\{,\\} bC BADBR",
205  "a{1,x} C BADBR",
206  "a\\{1,x\\} bC BADBR",
207  "a{1,x C EBRACE",
208  "a\\{1,x bC EBRACE",
209  "a{300} C BADBR",
210  "a\\{300\\} bC BADBR",
211  "a{1,0} C BADBR",
212  "a\\{1,0\\} bC BADBR",
213  "ab{0,0}c - abcac ac",
214  "ab\\{0,0\\}c b abcac ac",
215  "ab{0,1}c - abcac abc",
216  "ab\\{0,1\\}c b abcac abc",
217  "ab{0,3}c - abbcac abbc",
218  "ab\\{0,3\\}c b abbcac abbc",
219  "ab{1,1}c - acabc abc",
220  "ab\\{1,1\\}c b acabc abc",
221  "ab{1,3}c - acabc abc",
222  "ab\\{1,3\\}c b acabc abc",
223  "ab{2,2}c - abcabbc abbc",
224  "ab\\{2,2\\}c b abcabbc abbc",
225  "ab{2,4}c - abcabbc abbc",
226  "ab\\{2,4\\}c b abcabbc abbc",
227  "((a{1,10}){1,10}){1,10} - a a a,a",
228  "",
229  "# multiple repetitions",
230  "a** &C BADRPT",
231  "a++ C BADRPT",
232  "a?? C BADRPT",
233  "a*+ C BADRPT",
234  "a*? C BADRPT",
235  "a+* C BADRPT",
236  "a+? C BADRPT",
237  "a?* C BADRPT",
238  "a?+ C BADRPT",
239  "a{1}{1} C BADRPT",
240  "a*{1} C BADRPT",
241  "a+{1} C BADRPT",
242  "a?{1} C BADRPT",
243  "a{1}* C BADRPT",
244  "a{1}+ C BADRPT",
245  "a{1}? C BADRPT",
246  "a*{b} - a{b} a{b}",
247  "a\\{1\\}\\{1\\} bC BADRPT",
248  "a*\\{1\\} bC BADRPT",
249  "a\\{1\\}* bC BADRPT",
250  "",
251  "# brackets, and numerous perversions thereof",
252  "a[b]c & abc abc",
253  "a[ab]c & abc abc",
254  "a[^ab]c & adc adc",
255  "a[]b]c & a]c a]c",
256  "a[[b]c & a[c a[c",
257  "a[-b]c & a-c a-c",
258  "a[^]b]c & adc adc",
259  "a[^-b]c & adc adc",
260  "a[b-]c & a-c a-c",
261  "a[b &C EBRACK",
262  "a[] &C EBRACK",
263  "a[1-3]c & a2c a2c",
264  "a[3-1]c &C ERANGE",
265  "a[1-3-5]c &C ERANGE",
266  "a[[.-.]--]c & a-c a-c",
267  "a[1- &C ERANGE",
268  "a[[. &C EBRACK",
269  "a[[.x &C EBRACK",
270  "a[[.x. &C EBRACK",
271  "a[[.x.] &C EBRACK",
272  "a[[.x.]] & ax ax",
273  "a[[.x,.]] &C ECOLLATE",
274  "a[[.one.]]b & a1b a1b",
275  "a[[.notdef.]]b &C ECOLLATE",
276  "a[[.].]]b & a]b a]b",
277  "a[[:notdef:]]c &C ECTYPE",
278  "a[[: &C EBRACK",
279  "a[[:alpha &C EBRACK",
280  "a[[:alpha:] &C EBRACK",
281  "a[[:alpha,:] &C ECTYPE",
282  "a[[:]:]]b &C ECTYPE",
283  "a[[:-:]]b &C ECTYPE",
284  "a[[:alph:]] &C ECTYPE",
285  "a[[:alphabet:]] &C ECTYPE",
286  "[[:alnum:]]+ - -%@a5X- a5X",
287  "[[:alpha:]]+ - -%@aX0- aX",
288  "# ctype_latin1 does not tag '\\t' as blank, so we will match only two spaces.",
289  "# See: Bug #55427 REGEXP does not recognize '\\t' as [:blank:]",
290  "#[[:blank:]]+ - aSSTb SST",
291  "[[:blank:]]+ - aSSTb SS",
292  "[[:cntrl:]]+ - aNTb NT",
293  "[[:digit:]]+ - a019b 019",
294  "[[:graph:]]+ - Sa%bS a%b",
295  "[[:lower:]]+ - AabC ab",
296  "[[:print:]]+ - NaSbN aSb",
297  "[[:punct:]]+ - S%-&T %-&",
298  "[[:space:]]+ - aSNTb SNT",
299  "[[:upper:]]+ - aBCd BC",
300  "[[:xdigit:]]+ - p0f3Cq 0f3C",
301  "a[[=b=]]c & abc abc",
302  "a[[= &C EBRACK",
303  "a[[=b &C EBRACK",
304  "a[[=b= &C EBRACK",
305  "a[[=b=] &C EBRACK",
306  "a[[=b,=]] &C ECOLLATE",
307  "a[[=one=]]b & a1b a1b",
308  "",
309  "# complexities",
310  "a(((b)))c - abc abc",
311  "a(b|(c))d - abd abd",
312  "a(b*|c)d - abbd abbd",
313  "# just gotta have one DFA-buster, of course",
314  "a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab",
315  "# and an inline expansion in case somebody gets tricky",
316  "a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab",
317  "# and in case somebody just slips in an NFA...",
318  "a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights",
319  "# fish for anomalies as the number of states passes 32",
320  "12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789",
321  "123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890",
322  "1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901",
323  "12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012",
324  "123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123",
325  "# and one really big one, beyond any plausible word width",
326  "1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890",
327  "# fish for problems as brackets go past 8",
328  "[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm",
329  "[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo",
330  "[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq",
331  "[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq",
332  "",
333  "# subtleties of matching",
334  "abc & xabcy abc",
335  "a\\(b\\)?c\\1d b acd",
336  "aBc i Abc Abc",
337  "a[Bc]*d i abBCcd abBCcd",
338  "0[[:upper:]]1 &i 0a1 0a1",
339  "0[[:lower:]]1 &i 0A1 0A1",
340  "a[^b]c &i abc",
341  "a[^b]c &i aBc",
342  "a[^b]c &i adc adc",
343  "[a]b[c] - abc abc",
344  "[a]b[a] - aba aba",
345  "[abc]b[abc] - abc abc",
346  "[abc]b[abd] - abd abd",
347  "a(b?c)+d - accd accd",
348  "(wee|week)(knights|night) - weeknights weeknights",
349  "(we|wee|week|frob)(knights|night|day) - weeknights weeknights",
350  "a[bc]d - xyzaaabcaababdacd abd",
351  "a[ab]c - aaabc abc",
352  "abc s abc abc",
353  "a* & b @b",
354  "",
355  "# Let's have some fun -- try to match a C comment.",
356  "# first the obvious, which looks okay at first glance...",
357  "/\\*.*\\*/ - /*x*/ /*x*/",
358  "# but...",
359  "/\\*.*\\*/ - /*x*/y/*z*/ /*x*/y/*z*/",
360  "# okay, we must not match */ inside; try to do that...",
361  "/\\*([^*]|\\*[^/])*\\*/ - /*x*/ /*x*/",
362  "/\\*([^*]|\\*[^/])*\\*/ - /*x*/y/*z*/ /*x*/",
363  "# but...",
364  "/\\*([^*]|\\*[^/])*\\*/ - /*x**/y/*z*/ /*x**/y/*z*/",
365  "# and a still fancier version, which does it right (I think)...",
366  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x*/ /*x*/",
367  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x*/y/*z*/ /*x*/",
368  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x**/y/*z*/ /*x**/",
369  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x****/y/*z*/ /*x****/",
370  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x**x*/y/*z*/ /*x**x*/",
371  "/\\*([^*]|\\*+[^*/])*\\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/",
372  "",
373  "# subexpressions",
374  "a(b)(c)d - abcd abcd b,c",
375  "a(((b)))c - abc abc b,b,b",
376  "a(b|(c))d - abd abd b,-",
377  "a(b*|c|e)d - abbd abbd bb",
378  "a(b*|c|e)d - acd acd c",
379  "a(b*|c|e)d - ad ad @d",
380  "a(b?)c - abc abc b",
381  "a(b?)c - ac ac @c",
382  "a(b+)c - abc abc b",
383  "a(b+)c - abbbc abbbc bbb",
384  "a(b*)c - ac ac @c",
385  "(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de",
386  "# the regression tester only asks for 9 subexpressions",
387  "a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j",
388  "a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k",
389  "a([bc]?)c - abc abc b",
390  "a([bc]?)c - ac ac @c",
391  "a([bc]+)c - abc abc b",
392  "a([bc]+)c - abcc abcc bc",
393  "a([bc]+)bc - abcbc abcbc bc",
394  "a(bb+|b)b - abb abb b",
395  "a(bbb+|bb+|b)b - abb abb b",
396  "a(bbb+|bb+|b)b - abbb abbb bb",
397  "a(bbb+|bb+|b)bb - abbb abbb b",
398  "(.*).* - abcdef abcdef abcdef",
399  "(a*)* - bc @b @b",
400  "",
401  "# do we get the right subexpression when it is used more than once?",
402  "a(b|c)*d - ad ad -",
403  "a(b|c)*d - abcd abcd c",
404  "a(b|c)+d - abd abd b",
405  "a(b|c)+d - abcd abcd c",
406  "a(b|c?)+d - ad ad @d",
407  "a(b|c?)+d - abcd abcd @d",
408  "a(b|c){0,0}d - ad ad -",
409  "a(b|c){0,1}d - ad ad -",
410  "a(b|c){0,1}d - abd abd b",
411  "a(b|c){0,2}d - ad ad -",
412  "a(b|c){0,2}d - abcd abcd c",
413  "a(b|c){0,}d - ad ad -",
414  "a(b|c){0,}d - abcd abcd c",
415  "a(b|c){1,1}d - abd abd b",
416  "a(b|c){1,1}d - acd acd c",
417  "a(b|c){1,2}d - abd abd b",
418  "a(b|c){1,2}d - abcd abcd c",
419  "a(b|c){1,}d - abd abd b",
420  "a(b|c){1,}d - abcd abcd c",
421  "a(b|c){2,2}d - acbd acbd b",
422  "a(b|c){2,2}d - abcd abcd c",
423  "a(b|c){2,4}d - abcd abcd c",
424  "a(b|c){2,4}d - abcbd abcbd b",
425  "a(b|c){2,4}d - abcbcd abcbcd c",
426  "a(b|c){2,}d - abcd abcd c",
427  "a(b|c){2,}d - abcbd abcbd b",
428  "a(b+|((c)*))+d - abd abd @d,@d,-",
429  "a(b+|((c)*))+d - abcd abcd @d,@d,-",
430  "",
431  "# check out the STARTEND option",
432  "[abc] &# a(b)c b",
433  "[abc] &# a(d)c",
434  "[abc] &# a(bc)d b",
435  "[abc] &# a(dc)d c",
436  ". &# a()c",
437  "b.*c &# b(bc)c bc",
438  "b.* &# b(bc)c bc",
439  ".*c &# b(bc)c bc",
440  "",
441  "# plain strings, with the NOSPEC flag",
442  "abc m abc abc",
443  "abc m xabcy abc",
444  "abc m xyz",
445  "a*b m aba*b a*b",
446  "a*b m ab",
447  "\"\" mC EMPTY",
448  "",
449  "# cases involving NULs",
450  "aZb & a a",
451  "aZb &p a",
452  "aZb &p# (aZb) aZb",
453  "aZ*b &p# (ab) ab",
454  "a.b &# (aZb) aZb",
455  "a.* &# (aZb)c aZb",
456  "",
457  "# word boundaries (ick)",
458  "[[:<:]]a & a a",
459  "[[:<:]]a & ba",
460  "[[:<:]]a & -a a",
461  "a[[:>:]] & a a",
462  "a[[:>:]] & ab",
463  "a[[:>:]] & a- a",
464  "[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc",
465  "[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc",
466  "[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc",
467  "[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc",
468  "[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_",
469  "[[:<:]]a_b[[:>:]] & x_a_b",
470  "",
471  "# past problems, and suspected problems",
472  "(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1",
473  "abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop",
474  "abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv",
475  "(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11",
476  "CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11",
477  "Char \\([a-z0-9_]*\\)\\[.* b Char xyz[k Char xyz[k xyz",
478  "a?b - ab ab",
479  "-\\{0,1\\}[0-9]*$ b -5 -5",
480  "",
481  NULL
482 };