aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_expr_utf8.vim
diff options
context:
space:
mode:
authorMichael Ennen <mike.ennen@gmail.com>2016-10-23 17:38:28 -0700
committerMichael Ennen <mike.ennen@gmail.com>2016-10-23 22:55:22 -0700
commit6bc0d9b8c75b5bef61a951e56deb2b28f50182d8 (patch)
tree73c78cf426599fa3321b4f185eb3e19696d28b0c /src/nvim/testdir/test_expr_utf8.vim
parentb5dfdf0669c4ee1293d558543d7d96a374ac2e1d (diff)
downloadrneovim-6bc0d9b8c75b5bef61a951e56deb2b28f50182d8.tar.gz
rneovim-6bc0d9b8c75b5bef61a951e56deb2b28f50182d8.tar.bz2
rneovim-6bc0d9b8c75b5bef61a951e56deb2b28f50182d8.zip
vim-patch:7.4.1779
Problem: Using negative index in strcharpart(). (Yegappan Lakshmanan) Solution: Assume single byte when using a negative iindex. https://github.com/vim/vim/commit/73dfe917ba6357413aaf98a021c91add5ac6e9bc
Diffstat (limited to 'src/nvim/testdir/test_expr_utf8.vim')
-rw-r--r--src/nvim/testdir/test_expr_utf8.vim26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/nvim/testdir/test_expr_utf8.vim b/src/nvim/testdir/test_expr_utf8.vim
index 00d5d9a63a..7bdcb4f65f 100644
--- a/src/nvim/testdir/test_expr_utf8.vim
+++ b/src/nvim/testdir/test_expr_utf8.vim
@@ -4,29 +4,35 @@ if !has('multi_byte')
endif
scriptencoding utf-8
-func Test_strgetchar()
+func Test_strgetchar_utf8()
call assert_equal(char2nr('á'), strgetchar('áxb', 0))
call assert_equal(char2nr('x'), strgetchar('áxb', 1))
- call assert_equal(-1, strgetchar('axb', -1))
- call assert_equal(-1, strgetchar('axb', 3))
- call assert_equal(-1, strgetchar('', 0))
-
- call assert_equal(char2nr('a'), strgetchar('àxb', 0))
+ call assert_equal(char2nr('a'), strgetchar('àxb', 0))
call assert_equal(char2nr('̀'), strgetchar('àxb', 1))
- call assert_equal(char2nr('x'), strgetchar('àxb', 2))
+ call assert_equal(char2nr('x'), strgetchar('àxb', 2))
call assert_equal(char2nr('あ'), strgetchar('あaい', 0))
call assert_equal(char2nr('a'), strgetchar('あaい', 1))
call assert_equal(char2nr('い'), strgetchar('あaい', 2))
endfunc
-func Test_strcharpart()
+func Test_strcharpart_utf8()
call assert_equal('áxb', strcharpart('áxb', 0))
call assert_equal('á', strcharpart('áxb', 0, 1))
call assert_equal('x', strcharpart('áxb', 1, 1))
- call assert_equal('a', strcharpart('àxb', 0, 1))
+ call assert_equal('いうeお', strcharpart('あいうeお', 1))
+ call assert_equal('い', strcharpart('あいうeお', 1, 1))
+ call assert_equal('いう', strcharpart('あいうeお', 1, 2))
+ call assert_equal('いうe', strcharpart('あいうeお', 1, 3))
+ call assert_equal('いうeお', strcharpart('あいうeお', 1, 4))
+ call assert_equal('eお', strcharpart('あいうeお', 3))
+ call assert_equal('e', strcharpart('あいうeお', 3, 1))
+
+ call assert_equal('あ', strcharpart('あいうeお', -3, 4))
+
+ call assert_equal('a', strcharpart('àxb', 0, 1))
call assert_equal('̀', strcharpart('àxb', 1, 1))
- call assert_equal('x', strcharpart('àxb', 2, 1))
+ call assert_equal('x', strcharpart('àxb', 2, 1))
endfunc