diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-09 08:08:40 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-09 08:09:37 -0400 |
commit | 047dfcd29406350ef85a87a9e248b7b56261bd5f (patch) | |
tree | 73021555e9a462c07154500c3fd95adcc4dd3545 /src | |
parent | 4420dc3067a776271a94080a4b1b42a1e74bb2dc (diff) | |
download | rneovim-047dfcd29406350ef85a87a9e248b7b56261bd5f.tar.gz rneovim-047dfcd29406350ef85a87a9e248b7b56261bd5f.tar.bz2 rneovim-047dfcd29406350ef85a87a9e248b7b56261bd5f.zip |
vim-patch:8.1.0008: no test for strwidth()
Problem: No test for strwidth().
Solution: Add a test. (Dominique Pelle, closes vim/vim#2931)
https://github.com/vim/vim/commit/42ab17b8e32352210c4e273a4a4161a287d2c159
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 59445ebfe6..53911382b6 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -96,6 +96,30 @@ func Test_min() " call assert_fails('call min(v:none)', 'E712:') endfunc +func Test_strwidth() + for aw in ['single', 'double'] + exe 'set ambiwidth=' . aw + call assert_equal(0, strwidth('')) + call assert_equal(1, strwidth("\t")) + call assert_equal(3, strwidth('Vim')) + call assert_equal(4, strwidth(1234)) + call assert_equal(5, strwidth(-1234)) + + if has('multi_byte') + call assert_equal(2, strwidth('😉')) + call assert_equal(17, strwidth('Eĥoŝanĝo ĉiuĵaŭde')) + call assert_equal((aw == 'single') ? 6 : 7, strwidth('Straße')) + endif + + call assert_fails('call strwidth({->0})', 'E729:') + call assert_fails('call strwidth([])', 'E730:') + call assert_fails('call strwidth({})', 'E731:') + call assert_fails('call strwidth(1.2)', 'E806:') + endfor + + set ambiwidth& +endfunc + func Test_str2nr() call assert_equal(0, str2nr('')) call assert_equal(1, str2nr('1')) |