tests
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:12k
源码类别:

MySQL数据库

开发平台:

Visual C++

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