Mercurial > vim
annotate src/testdir/test_utf8.vim @ 16148:90b0f2227d73 v8.1.1079
patch 8.1.1079: no need for a separate ScreenLinesUtf8() test function
commit https://github.com/vim/vim/commit/48aed0824e47147faf19fc235ad4bcf851584c9c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 30 15:44:17 2019 +0100
patch 8.1.1079: no need for a separate ScreenLinesUtf8() test function
Problem: No need for a separate ScreenLinesUtf8() test function.
Solution: Get the composing characters with ScreenLines().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Mar 2019 15:45:05 +0100 |
parents | eb087f8a26a8 |
children | 219c58b3879c |
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 |
16133
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
3 source view_util.vim |
10720
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " 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
|
6 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
|
7 new |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 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
|
9 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
|
10 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
|
11 bwipeout! |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " 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
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 endfor |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 endfunc |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " Test for customlist completion |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
26 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
|
27 return ['あ', 'い'] |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
28 endfunc |
10720
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
30 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
|
31 return ['あたし', 'あたま', 'あたりめ'] |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
32 endfunc |
10720
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
34 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
|
35 return ['Nこ', 'Nん', 'Nぶ'] |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
10720
diff
changeset
|
36 endfunc |
10720
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 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
|
52 endfunc |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 " 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
|
55 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
|
56 new |
44a1661f4cfa
patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 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
|
58 normal 0lvy |
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(2, 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(4, col("']")) |
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 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
|
63 endfunc |
16133
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
64 |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
65 func Test_screenchar_utf8() |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
66 new |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
67 |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
68 " 1-cell, with composing characters |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
69 call setline(1, ["ABC\u0308"]) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
70 redraw |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
71 call assert_equal([0x0041], screenchars(1, 1)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
72 call assert_equal([0x0042], screenchars(1, 2)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
73 call assert_equal([0x0043, 0x0308], screenchars(1, 3)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
74 call assert_equal("A", screenstring(1, 1)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
75 call assert_equal("B", screenstring(1, 2)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
76 call assert_equal("C\u0308", screenstring(1, 3)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
77 |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
78 " 2-cells, with composing characters |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
79 let text = "\u3042\u3044\u3046\u3099" |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
80 call setline(1, text) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
81 redraw |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
82 call assert_equal([0x3042], screenchars(1, 1)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
83 call assert_equal([0], screenchars(1, 2)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
84 call assert_equal([0x3044], screenchars(1, 3)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
85 call assert_equal([0], screenchars(1, 4)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
86 call assert_equal([0x3046, 0x3099], screenchars(1, 5)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
87 |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
88 call assert_equal("\u3042", screenstring(1, 1)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
89 call assert_equal("", screenstring(1, 2)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
90 call assert_equal("\u3044", screenstring(1, 3)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
91 call assert_equal("", screenstring(1, 4)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
92 call assert_equal("\u3046\u3099", screenstring(1, 5)) |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
93 |
16148
90b0f2227d73
patch 8.1.1079: no need for a separate ScreenLinesUtf8() test function
Bram Moolenaar <Bram@vim.org>
parents:
16133
diff
changeset
|
94 call assert_equal([text . ' '], ScreenLines(1, 8)) |
16133
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
95 |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
96 bwipe! |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
97 endfunc |