# HG changeset patch # User Christian Brabandt # Date 1526818506 -7200 # Node ID a9e31b01366b87c9ac3b7502da47c572d5e25f3b # Parent 240fa79f3241f61182c2a285b74bf9d2a3e7308d patch 8.1.0008: no test for strwidth() commit https://github.com/vim/vim/commit/42ab17b8e32352210c4e273a4a4161a287d2c159 Author: Bram Moolenaar Date: Sun May 20 14:11:10 2018 +0200 patch 8.1.0008: no test for strwidth() Problem: No test for strwidth(). Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/2931) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -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')) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 8, +/**/ 7, /**/ 6,