Skip to content

Commit 42ab17b

Browse files
committed
patch 8.1.0008: no test for strwidth()
Problem: No test for strwidth(). Solution: Add a test. (Dominique Pelle, closes #2931)
1 parent 2e94976 commit 42ab17b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/testdir/test_functions.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ func Test_min()
9696
call assert_fails('call min(v:none)', 'E712:')
9797
endfunc
9898

99+
func Test_strwidth()
100+
for aw in ['single', 'double']
101+
exe 'set ambiwidth=' . aw
102+
call assert_equal(0, strwidth(''))
103+
call assert_equal(1, strwidth("\t"))
104+
call assert_equal(3, strwidth('Vim'))
105+
call assert_equal(4, strwidth(1234))
106+
call assert_equal(5, strwidth(-1234))
107+
108+
if has('multi_byte')
109+
call assert_equal(2, strwidth('😉'))
110+
call assert_equal(17, strwidth('Eĥoŝanĝo ĉiuĵaŭde'))
111+
call assert_equal((aw == 'single') ? 6 : 7, strwidth('Straße'))
112+
endif
113+
114+
call assert_fails('call strwidth({->0})', 'E729:')
115+
call assert_fails('call strwidth([])', 'E730:')
116+
call assert_fails('call strwidth({})', 'E731:')
117+
call assert_fails('call strwidth(1.2)', 'E806:')
118+
endfor
119+
120+
set ambiwidth&
121+
endfunc
122+
99123
func Test_str2nr()
100124
call assert_equal(0, str2nr(''))
101125
call assert_equal(1, str2nr('1'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
8,
764766
/**/
765767
7,
766768
/**/

0 commit comments

Comments
 (0)