annotate src/testdir/test_utf8.vim @ 15607:2dcaa860e3fc v8.1.0811

patch 8.1.0811: too many #ifdefs commit https://github.com/vim/vim/commit/30276f2beb248557c6b33cd5418bca8b7084b0a5 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 24 17:59:39 2019 +0100 patch 8.1.0811: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate FEAT_MBYTE, the final chapter.
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Jan 2019 18:00:07 +0100
parents 63b02fcf1361
children eb087f8a26a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for Unicode manipulations
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " Visual block Insert adjusts for multi-byte char
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_visual_block_insert()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 new
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call setline(1, ["aaa", "あああ", "bbb"])
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 exe ":norm! gg0l\<C-V>jjIx\<Esc>"
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 bwipeout!
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " Test for built-in function strchars()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 func Test_strchars()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"]
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 for i in range(len(inp))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal(exp[i][0], strchars(inp[i]))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(exp[i][1], strchars(inp[i], 0))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(exp[i][2], strchars(inp[i], 1))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endfor
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " Test for customlist completion
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
25 func CustomComplete1(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 return ['あ', 'い']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
27 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
29 func CustomComplete2(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 return ['あたし', 'あたま', 'あたりめ']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
31 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
33 func CustomComplete3(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 return ['Nこ', 'Nん', 'Nぶ']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
35 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 func Test_customlist_completion()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call feedkeys(":Test1 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal('"Test1 ', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call feedkeys(":Test2 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal('"Test2 あた', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call feedkeys(":Test3 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal('"Test3 N', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call garbagecollect(1)
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Yank one 3 byte character and check the mark columns.
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 func Test_getvcol()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 new
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call setline(1, "x\u2500x")
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 normal 0lvy
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal(2, col("'["))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(4, col("']"))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_equal(2, virtcol("'["))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call assert_equal(2, virtcol("']"))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 endfunc