comparison src/testdir/test_expr_utf8.vim @ 8895:7f29248d5789 v7.4.1734

commit https://github.com/vim/vim/commit/0f518a8f4d4be4cac10389680f6bd5e3781f94b0 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 14 16:57:10 2016 +0200 patch 7.4.1734 Problem: Test fails when not using utf-8. Solution: Split test in regularand utf-8 part.
author Christian Brabandt <cb@256bit.org>
date Thu, 14 Apr 2016 17:00:05 +0200
parents
children 6393ac6d7060
comparison
equal deleted inserted replaced
8894:fb27c2029d7b 8895:7f29248d5789
1 " Tests for expressions using utf-8.
2 if !has('multi_byte')
3 finish
4 endif
5 set encoding=utf-8
6 scriptencoding utf-8
7
8 func Test_strgetchar()
9 call assert_equal(char2nr('a'), strgetchar('axb', 0))
10 call assert_equal(char2nr('x'), strgetchar('axb', 1))
11 call assert_equal(char2nr('b'), strgetchar('axb', 2))
12
13 call assert_equal(-1, strgetchar('axb', -1))
14 call assert_equal(-1, strgetchar('axb', 3))
15 call assert_equal(-1, strgetchar('', 0))
16 endfunc
17
18 func Test_strcharpart()
19 call assert_equal('áxb', strcharpart('áxb', 0))
20 call assert_equal('á', strcharpart('áxb', 0, 1))
21 call assert_equal('x', strcharpart('áxb', 1, 1))
22
23 call assert_equal('a', strcharpart('àxb', 0, 1))
24 call assert_equal('̀', strcharpart('àxb', 1, 1))
25 call assert_equal('x', strcharpart('àxb', 2, 1))
26 endfunc