diff options
author | Michael Ennen <mike.ennen@gmail.com> | 2016-10-23 16:59:24 -0700 |
---|---|---|
committer | Michael Ennen <mike.ennen@gmail.com> | 2016-10-23 18:04:46 -0700 |
commit | 763422b0365cd9270dc495f31e75e75913516088 (patch) | |
tree | 81cf9c4c48f9fa7cbeddca3245c1fab82e2e0cc8 /src/nvim/testdir/test_expr_utf8.vim | |
parent | d6e27f90b9ce19852d14e74c9e8a883f6c2207d7 (diff) | |
download | rneovim-763422b0365cd9270dc495f31e75e75913516088.tar.gz rneovim-763422b0365cd9270dc495f31e75e75913516088.tar.bz2 rneovim-763422b0365cd9270dc495f31e75e75913516088.zip |
vim-patch:7.4.1734
Problem: Test fails when not using utf-8.
Solution: Split test in regularand utf-8 part.
https://github.com/vim/vim/commit/0f518a8f4d4be4cac10389680f6bd5e3781f94b0
Diffstat (limited to 'src/nvim/testdir/test_expr_utf8.vim')
-rw-r--r-- | src/nvim/testdir/test_expr_utf8.vim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_expr_utf8.vim b/src/nvim/testdir/test_expr_utf8.vim new file mode 100644 index 0000000000..85cddbb13a --- /dev/null +++ b/src/nvim/testdir/test_expr_utf8.vim @@ -0,0 +1,33 @@ +" Tests for expressions using utf-8. +if !has('multi_byte') + finish +endif +scriptencoding utf-8 + +func Test_strgetchar() + call assert_equal(char2nr('a'), strgetchar('axb', 0)) + call assert_equal(char2nr('x'), strgetchar('axb', 1)) + call assert_equal(char2nr('b'), strgetchar('axb', 2)) + + 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('̀'), strgetchar('àxb', 1)) + 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() + 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('̀', strcharpart('àxb', 1, 1)) + call assert_equal('x', strcharpart('àxb', 2, 1)) +endfunc |