]> granicus.if.org Git - vim/commitdiff
patch 8.1.0008: no test for strwidth() v8.1.0008
authorBram Moolenaar <Bram@vim.org>
Sun, 20 May 2018 12:11:10 +0000 (14:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 May 2018 12:11:10 +0000 (14:11 +0200)
Problem:    No test for strwidth().
Solution:   Add a test. (Dominique Pelle, closes #2931)

src/testdir/test_functions.vim
src/version.c

index 49e5d1f1a6c0ff922f6aacd8a0161b57c170b97c..97e7e234ad890186156477f56598fc0502d407d9 100644 (file)
@@ -96,6 +96,30 @@ func Test_min()
   call assert_fails('call min(v:none)', 'E712:')
 endfunc
 
+func Test_strwidth()
+  for aw in ['single', 'double']
+    exe 'set ambiwidth=' . aw
+    call assert_equal(0, strwidth(''))
+    call assert_equal(1, strwidth("\t"))
+    call assert_equal(3, strwidth('Vim'))
+    call assert_equal(4, strwidth(1234))
+    call assert_equal(5, strwidth(-1234))
+
+    if has('multi_byte')
+      call assert_equal(2, strwidth('😉'))
+      call assert_equal(17, strwidth('Eĥoŝanĝo ĉiuĵaŭde'))
+      call assert_equal((aw == 'single') ? 6 : 7, strwidth('Straße'))
+    endif
+
+    call assert_fails('call strwidth({->0})', 'E729:')
+    call assert_fails('call strwidth([])', 'E730:')
+    call assert_fails('call strwidth({})', 'E731:')
+    call assert_fails('call strwidth(1.2)', 'E806:')
+  endfor
+
+  set ambiwidth&
+endfunc
+
 func Test_str2nr()
   call assert_equal(0, str2nr(''))
   call assert_equal(1, str2nr('1'))
index f18e711fba55a8ea49037341824a662149066da1..f2fa2a701aa3251ada6af24ea1450e76056f7772 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    8,
 /**/
     7,
 /**/