blob: fb78b88dd17dbc8e4d663f9a82de7b92f38147a2 [file] [log] [blame]
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02001Test for regexp patterns with multi-byte support.
2See test64 for the non-multi-byte tests.
3
4A pattern that gives the expected result produces OK, so that we know it was
5actually tried.
6
7STARTTEST
8:so small.vim
9:so mbyte.vim
10:" tl is a List of Lists with:
11:" regexp pattern
12:" text to test the pattern on
13:" expected match (optional)
14:" expected submatch 1 (optional)
15:" expected submatch 2 (optional)
16:" etc.
17:" When there is no match use only the first two items.
18:let tl = []
19
20:"""" Multi-byte character tests. These will fail unless vim is compiled
21:"""" with Multibyte (FEAT_MBYTE) or BIG/HUGE features.
22:call add(tl, ['[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna'])
23:call add(tl, ['[[=a=]]\+', 'ddaãâbcd', 'aãâ']) " equivalence classes
24:call add(tl, ['[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos'])
25:call add(tl, [' [^ ]\+', 'start มabcdม ', ' มabcdม'])
26:call add(tl, ['[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna'])
27
Bram Moolenaar0fabe3f2013-05-21 12:34:17 +020028:" this is not a normal "i" but 0xec
29:call add(tl, ['\p\+', 'ìa', 'ìa'])
30
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020031:"""" Run the tests
32
33:"
34:for t in tl
35: let l = matchlist(t[1], t[0])
36:" check the match itself
37: if len(l) == 0 && len(t) > 2
38: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
39: elseif len(l) > 0 && len(t) == 2
40: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
41: elseif len(t) > 2 && l[0] != t[2]
42: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
43: else
44: $put ='OK - ' . t[0]
45: endif
46: if len(l) > 0
47:" check all the nine submatches
48: for i in range(1, 9)
49: if len(t) <= i + 2
50: let e = ''
51: else
52: let e = t[i + 2]
53: endif
54: if l[i] != e
55: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
56: endif
57: endfor
58: unlet i
59: endif
60:endfor
61:unlet t tl e l
62
63:/\%#=1^Results/,$wq! test.out
64ENDTEST
65
66Results of test95: