annotate src/testdir/test_utf8_comparisons.vim @ 11603:4e66689bced6 v8.0.0684

patch 8.0.0684: old style tests are not nice commit https://github.com/vim/vim/commit/28b238225ae618f63cfe5d3d723120960a941da7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 27 18:29:17 2017 +0200 patch 8.0.0684: old style tests are not nice Problem: Old style tests are not nice. Solution: Turn two tests into new style. (pschuh, closes https://github.com/vim/vim/issues/1797)
author Christian Brabandt <cb@256bit.org>
date Tue, 27 Jun 2017 18:30:03 +0200
parents
children 63b02fcf1361
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11603
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Also test "g~ap".
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 if !has("multi_byte")
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 finish
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 function! Ch(a, op, b, expected)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_equal(eval(printf('"%s" %s "%s"', a:a, a:op, a:b)), a:expected,
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 \ printf('"%s" %s "%s" should return %d', a:a, a:op, a:b, a:expected))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 function! Chk(a, b, result)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 if a:result == 0
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call Ch(a:a, '==?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call Ch(a:a, '!=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call Ch(a:a, '<=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call Ch(a:a, '>=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call Ch(a:a, '<?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call Ch(a:a, '>?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 elseif a:result > 0
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call Ch(a:a, '==?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call Ch(a:a, '!=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call Ch(a:a, '<=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call Ch(a:a, '>=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call Ch(a:a, '<?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call Ch(a:a, '>?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 else
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call Ch(a:a, '==?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call Ch(a:a, '!=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call Ch(a:a, '<=?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call Ch(a:a, '>=?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call Ch(a:a, '<?', a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call Ch(a:a, '>?', a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 endif
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 function! Check(a, b, result)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call Chk(a:a, a:b, a:result)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call Chk(a:b, a:a, -a:result)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 function! LT(a, b)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call Check(a:a, a:b, -1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 function! GT(a, b)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call Check(a:a, a:b, 1)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 function! EQ(a, b)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call Check(a:a, a:b, 0)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 function Test_comparisons()
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call EQ('', '')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call LT('', 'a')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call EQ('abc', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call EQ('Abc', 'abC')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call LT('ab', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call LT('AB', 'abc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call LT('ab', 'aBc')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call EQ('\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd', '\xd0\xb9\xd0\xa6\xd0\xa3\xd0\xba\xd0\x95\xd0\xbd')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call LT('\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd', '\xd0\xaf\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call EQ('\xe2\x84\xaa', 'k')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call LT('\xe2\x84\xaa', 'kkkkkk')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 call EQ('\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa', 'kkk')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call LT('kk', '\xe2\x84\xaa\xe2\x84\xaa\xe2\x84\xaa')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call EQ('\xe2\x84\xaa\xe2\x84\xa6k\xe2\x84\xaak\xcf\x89', 'k\xcf\x89\xe2\x84\xaakk\xe2\x84\xa6')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call EQ('Abc\x80', 'AbC\x80')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call LT('Abc\x80', 'AbC\x81')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call LT('Abc', 'AbC\x80')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call LT('abc\x80DEF', 'abc\x80def') " case folding stops at the first bad character
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call LT('\xc3XYZ', '\xc3xyz')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 call EQ('\xef\xbc\xba', '\xef\xbd\x9a') " FF3A (upper), FF5A (lower)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call GT('\xef\xbc\xba', '\xef\xbc\xff') " first string is ok and equals \xef\xbd\x9a after folding, second string is illegal and was left unchanged, then the strings were bytewise compared
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call LT('\xc3', '\xc3\x83')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call EQ('\xc3\xa3xYz', '\xc3\x83XyZ')
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 for n in range(0x60, 0xFF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 call LT(printf('xYz\x%.2X', n-1), printf('XyZ\x%.2X', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endfor
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 for n in range(0x80, 0xBF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 call EQ(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endfor
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 for n in range(0xC0, 0xFF)
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call LT(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 endfor
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endfunction
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 " test that g~ap changes one paragraph only.
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 function Test_gap()
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 new
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 call feedkeys("iabcd\n\ndefggg0g~ap", "tx")
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call assert_equal(["ABCD", "", "defg"], getline(1,3))
4e66689bced6 patch 8.0.0684: old style tests are not nice
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 endfunction