Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 1 | " Tests for Unicode manipulations |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 2 | |
| 3 | |
| 4 | " Visual block Insert adjusts for multi-byte char |
| 5 | func Test_visual_block_insert() |
| 6 | new |
| 7 | call setline(1, ["aaa", "あああ", "bbb"]) |
| 8 | exe ":norm! gg0l\<C-V>jjIx\<Esc>" |
| 9 | call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$')) |
| 10 | bwipeout! |
| 11 | endfunc |
| 12 | |
| 13 | " Test for built-in function strchars() |
| 14 | func Test_strchars() |
| 15 | let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"] |
| 16 | let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]] |
| 17 | for i in range(len(inp)) |
| 18 | call assert_equal(exp[i][0], strchars(inp[i])) |
| 19 | call assert_equal(exp[i][1], strchars(inp[i], 0)) |
| 20 | call assert_equal(exp[i][2], strchars(inp[i], 1)) |
| 21 | endfor |
| 22 | endfunc |
| 23 | |
| 24 | " Test for customlist completion |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 25 | func CustomComplete1(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 26 | return ['あ', 'い'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 27 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 28 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 29 | func CustomComplete2(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 30 | return ['あたし', 'あたま', 'あたりめ'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 31 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 32 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 33 | func CustomComplete3(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 34 | return ['Nこ', 'Nん', 'Nぶ'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 35 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 36 | |
| 37 | func Test_customlist_completion() |
| 38 | command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo |
| 39 | call feedkeys(":Test1 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 40 | call assert_equal('"Test1 ', getreg(':')) |
| 41 | |
| 42 | command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo |
| 43 | call feedkeys(":Test2 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 44 | call assert_equal('"Test2 あた', getreg(':')) |
| 45 | |
| 46 | command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo |
| 47 | call feedkeys(":Test3 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 48 | call assert_equal('"Test3 N', getreg(':')) |
| 49 | |
| 50 | call garbagecollect(1) |
| 51 | endfunc |
| 52 | |
| 53 | " Yank one 3 byte character and check the mark columns. |
| 54 | func Test_getvcol() |
| 55 | new |
| 56 | call setline(1, "x\u2500x") |
| 57 | normal 0lvy |
| 58 | call assert_equal(2, col("'[")) |
| 59 | call assert_equal(4, col("']")) |
| 60 | call assert_equal(2, virtcol("'[")) |
| 61 | call assert_equal(2, virtcol("']")) |
| 62 | endfunc |