From: Bram Moolenaar Date: Wed, 7 Oct 2020 14:54:52 +0000 (+0200) Subject: patch 8.2.1810: some code in normal.c not covered by tests X-Git-Tag: v8.2.1810 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7e5e9430ae192c76f1f03c3ac53fae823d94c33;p=vim patch 8.2.1810: some code in normal.c not covered by tests Problem: Some code in normal.c not covered by tests. Solution: Add normal mode tests. (Yegappan Lakshmanan, closes #7086) --- diff --git a/src/testdir/test_charsearch.vim b/src/testdir/test_charsearch.vim index 78e991d8c..06b8ff6ce 100644 --- a/src/testdir/test_charsearch.vim +++ b/src/testdir/test_charsearch.vim @@ -51,7 +51,7 @@ func Test_csearch_virtualedit() normal! tb call assert_equal([0, 1, 2, 6], getpos('.')) set virtualedit& - close! + bw! endfunc " Test for character search failure in latin1 encoding @@ -65,7 +65,34 @@ func Test_charsearch_latin1() call assert_beeps('normal $Fz') call assert_beeps('normal $Tx') let &encoding = save_enc - close! + bw! +endfunc + +" Test for using character search to find a multibyte character with composing +" characters. +func Test_charsearch_composing_char() + new + call setline(1, "one two thq\u0328\u0301r\u0328\u0301ree") + call feedkeys("fr\u0328\u0301", 'xt') + call assert_equal([0, 1, 16, 0, 12], getcurpos()) + + " use character search with a multi-byte character followed by a + " non-composing character + call setline(1, "abc deȉf ghi") + call feedkeys("ggcf\u0209\u0210", 'xt') + call assert_equal("\u0210f ghi", getline(1)) + bw! +endfunc + +" Test for character search with 'hkmap' +func Test_charsearch_hkmap() + new + set hkmap + call setline(1, "ùðáâ÷ëòéïçìêöî") + call feedkeys("fë", 'xt') + call assert_equal([0, 1, 11, 0, 6], getcurpos()) + set hkmap& + bw! endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index bae5d8d0a..d2f1fab57 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -118,6 +118,39 @@ func Test_normal01_keymodel() call feedkeys("Vkk\yy", 'tx') call assert_equal(['47', '48', '49', '50'], getreg(0, 0, 1)) + " Test for using special keys to start visual selection + %d + call setline(1, ['red fox tail', 'red fox tail', 'red fox tail']) + set keymodel=startsel + " Test for and + call cursor(1, 1) + call feedkeys("\y", 'xt') + call assert_equal([0, 1, 1, 0], getpos("'<")) + call assert_equal([0, 3, 1, 0], getpos("'>")) + call feedkeys("Gz\8|\y", 'xt') + call assert_equal([0, 2, 1, 0], getpos("'<")) + call assert_equal([0, 3, 8, 0], getpos("'>")) + " Test for and + call cursor(2, 12) + call feedkeys("\y", 'xt') + call assert_equal([0, 1, 1, 0], getpos("'<")) + call assert_equal([0, 2, 12, 0], getpos("'>")) + call cursor(1, 4) + call feedkeys("\y", 'xt') + call assert_equal([0, 1, 4, 0], getpos("'<")) + call assert_equal([0, 3, 13, 0], getpos("'>")) + " Test for and + call cursor(2, 5) + call feedkeys("\y", 'xt') + call assert_equal([0, 2, 5, 0], getpos("'<")) + call assert_equal([0, 2, 9, 0], getpos("'>")) + call cursor(2, 9) + call feedkeys("\y", 'xt') + call assert_equal([0, 2, 5, 0], getpos("'<")) + call assert_equal([0, 2, 9, 0], getpos("'>")) + + set keymodel& + " clean up bw! endfunc @@ -409,6 +442,14 @@ func Test_normal10_expand() call assert_equal(expected[i], expand(''), 'i == ' . i) endfor + " Test for in state.val and ptr->val + call setline(1, 'x = state.val;') + call cursor(1, 10) + call assert_equal('state.val', expand('')) + call setline(1, 'x = ptr->val;') + call cursor(1, 9) + call assert_equal('ptr->val', expand('')) + if executable('echo') " Test expand(`...`) i.e. backticks command expansion. call assert_equal('abcde', expand('`echo abcde`')) @@ -422,6 +463,19 @@ func Test_normal10_expand() bw! endfunc +" Test for expand() in latin1 encoding +func Test_normal_expand_latin1() + new + let save_enc = &encoding + set encoding=latin1 + call setline(1, 'val = item->color;') + call cursor(1, 11) + call assert_equal('color', expand("")) + call assert_equal('item->color', expand("")) + let &encoding = save_enc + bw! +endfunc + func Test_normal11_showcmd() " test for 'showcmd' 10new @@ -446,6 +500,13 @@ func Test_normal11_showcmd() redraw! call assert_match('1-3$', Screenline(&lines)) call feedkeys("v", 'xt') + " test for visually selecting the end of line + call setline(1, ["foobar"]) + call feedkeys("$vl", 'xt') + redraw! + call assert_match('2$', Screenline(&lines)) + call feedkeys("y", 'xt') + call assert_equal("r\n", @") bw! endfunc @@ -2021,6 +2082,13 @@ func Test_normal31_r_cmd() normal gglvjjrx call assert_equal(['axx', 'xxx', 'xxf'], getline(1, '$')) + " replace with a multibyte character (with multiple composing characters) + %d + new + call setline(1, 'aaa') + exe "normal $ra\u0328\u0301" + call assert_equal("aaa\u0328\u0301", getline(1)) + " clean up set noautoindent bw! diff --git a/src/version.c b/src/version.c index 9c4029fa7..140b3c8e2 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1810, /**/ 1809, /**/