1 " Tests for Unicode manipulations
7 " Visual block Insert adjusts for multi-byte char
8 func Test_visual_block_insert()
10 call setline(1, ["aaa", "あああ", "bbb"])
11 exe ":norm! gg0l\<C-V>jjIx\<Esc>"
12 call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$'))
16 " Test for built-in function strchars()
18 let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"]
19 let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
20 for i in range(len(inp))
21 call assert_equal(exp[i][0], strchars(inp[i]))
22 call assert_equal(exp[i][1], strchars(inp[i], 0))
23 call assert_equal(exp[i][2], strchars(inp[i], 1))
27 " Test for customlist completion
28 function! CustomComplete1(lead, line, pos)
32 function! CustomComplete2(lead, line, pos)
33 return ['あたし', 'あたま', 'あたりめ']
36 function! CustomComplete3(lead, line, pos)
37 return ['Nこ', 'Nん', 'Nぶ']
40 func Test_customlist_completion()
41 command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo
42 call feedkeys(":Test1 \<C-L>\<C-B>\"\<CR>", 'itx')
43 call assert_equal('"Test1 ', getreg(':'))
45 command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo
46 call feedkeys(":Test2 \<C-L>\<C-B>\"\<CR>", 'itx')
47 call assert_equal('"Test2 あた', getreg(':'))
49 command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo
50 call feedkeys(":Test3 \<C-L>\<C-B>\"\<CR>", 'itx')
51 call assert_equal('"Test3 N', getreg(':'))
53 call garbagecollect(1)
56 " Yank one 3 byte character and check the mark columns.
59 call setline(1, "x\u2500x")
61 call assert_equal(2, col("'["))
62 call assert_equal(4, col("']"))
63 call assert_equal(2, virtcol("'["))
64 call assert_equal(2, virtcol("']"))