diff options
author | James McCoy <jamessan@jamessan.com> | 2016-10-31 10:13:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 10:13:41 -0400 |
commit | 859e9fa65f539020a15794a98bc8eff2f9538ded (patch) | |
tree | 36584f5b9667c461dd8d98c5ce3fde25d1cd9f6b /src/nvim/testdir/test_expr_utf8.vim | |
parent | ed198737fd739dcd4960763028a73e4efd83c452 (diff) | |
parent | f6f77272b3233ea2926e2d7fb2c007e381a85ea1 (diff) | |
download | rneovim-859e9fa65f539020a15794a98bc8eff2f9538ded.tar.gz rneovim-859e9fa65f539020a15794a98bc8eff2f9538ded.tar.bz2 rneovim-859e9fa65f539020a15794a98bc8eff2f9538ded.zip |
Merge pull request #5527 from brcolow/vim-7.4.1730
vim-patch:7.4.[1730,1734,1741,1742,1779,1782]
Diffstat (limited to 'src/nvim/testdir/test_expr_utf8.vim')
-rw-r--r-- | src/nvim/testdir/test_expr_utf8.vim | 38 |
1 files changed, 38 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..7bdcb4f65f --- /dev/null +++ b/src/nvim/testdir/test_expr_utf8.vim @@ -0,0 +1,38 @@ +" Tests for expressions using utf-8. +if !has('multi_byte') + finish +endif +scriptencoding utf-8 + +func Test_strgetchar_utf8() + call assert_equal(char2nr('á'), strgetchar('áxb', 0)) + call assert_equal(char2nr('x'), strgetchar('áxb', 1)) + + 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_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('いう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)) +endfunc |