1" Tests for Unicode manipulations 2if !has('multi_byte') 3 finish 4endif 5 6 7" Visual block Insert adjusts for multi-byte char 8func Test_visual_block_insert() 9 new 10 call setline(1, ["aaa", "あああ", "bbb"]) 11 exe ":norm! gg0l\<C-V>jjIx\<Esc>" 12 call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$')) 13 bwipeout! 14endfunc 15 16" Test for built-in function strchars() 17func Test_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)) 24 endfor 25endfunc 26 27" Test for customlist completion 28function! CustomComplete1(lead, line, pos) 29 return ['あ', 'い'] 30endfunction 31 32function! CustomComplete2(lead, line, pos) 33 return ['あたし', 'あたま', 'あたりめ'] 34endfunction 35 36function! CustomComplete3(lead, line, pos) 37 return ['Nこ', 'Nん', 'Nぶ'] 38endfunction 39 40func 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(':')) 44 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(':')) 48 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(':')) 52 53 call garbagecollect(1) 54endfunc 55 56" Yank one 3 byte character and check the mark columns. 57func Test_getvcol() 58 new 59 call setline(1, "x\u2500x") 60 normal 0lvy 61 call assert_equal(2, col("'[")) 62 call assert_equal(4, col("']")) 63 call assert_equal(2, virtcol("'[")) 64 call assert_equal(2, virtcol("']")) 65endfunc 66