diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-14 16:57:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-14 16:57:10 +0200 |
commit | 0f518a8f4d4be4cac10389680f6bd5e3781f94b0 (patch) | |
tree | 03e73f418451f8a7019a60fae27ccf5561529467 /src/testdir/test_expr_utf8.vim | |
parent | 839e954aaa72ef62f65416d177f829e681c15466 (diff) | |
download | vim-git-0f518a8f4d4be4cac10389680f6bd5e3781f94b0.tar.gz |
patch 7.4.1734v7.4.1734
Problem: Test fails when not using utf-8.
Solution: Split test in regularand utf-8 part.
Diffstat (limited to 'src/testdir/test_expr_utf8.vim')
-rw-r--r-- | src/testdir/test_expr_utf8.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testdir/test_expr_utf8.vim b/src/testdir/test_expr_utf8.vim new file mode 100644 index 000000000..8b10e6300 --- /dev/null +++ b/src/testdir/test_expr_utf8.vim @@ -0,0 +1,26 @@ +" Tests for expressions using utf-8. +if !has('multi_byte') + finish +endif +set encoding=utf-8 +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)) +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 |