Skip to content

Commit c7d16dc

Browse files
committed
patch 8.0.1311: no test for strpart()
Problem: No test for strpart(). Solution: Add a test. (Dominique Pelle, closes #2347)
1 parent 0f1e643 commit c7d16dc

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

src/testdir/test_functions.vim

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
" Tests for various functions.
22

3+
" Must be done first, since the alternate buffer must be unset.
4+
func Test_00_bufexists()
5+
call assert_equal(0, bufexists('does_not_exist'))
6+
call assert_equal(1, bufexists(bufnr('%')))
7+
call assert_equal(0, bufexists(0))
8+
new Xfoo
9+
let bn = bufnr('%')
10+
call assert_equal(1, bufexists(bn))
11+
call assert_equal(1, bufexists('Xfoo'))
12+
call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
13+
call assert_equal(1, bufexists(0))
14+
bw
15+
call assert_equal(0, bufexists(bn))
16+
call assert_equal(0, bufexists('Xfoo'))
17+
endfunc
18+
319
func Test_empty()
420
call assert_equal(1, empty(''))
521
call assert_equal(0, empty('a'))
@@ -168,6 +184,19 @@ func Test_simplify()
168184
call assert_fails('call simplify(1.2)', 'E806:')
169185
endfunc
170186

187+
func Test_strpart()
188+
call assert_equal('de', strpart('abcdefg', 3, 2))
189+
call assert_equal('ab', strpart('abcdefg', -2, 4))
190+
call assert_equal('abcdefg', strpart('abcdefg', -2))
191+
call assert_equal('fg', strpart('abcdefg', 5, 4))
192+
call assert_equal('defg', strpart('abcdefg', 3))
193+
194+
if has('multi_byte')
195+
call assert_equal('lép', strpart('éléphant', 2, 4))
196+
call assert_equal('léphant', strpart('éléphant', 2))
197+
endif
198+
endfunc
199+
171200
func Test_tolower()
172201
call assert_equal("", tolower(""))
173202

@@ -478,21 +507,6 @@ func Test_getbufvar()
478507
set fileformats&
479508
endfunc
480509

481-
func Test_bufexists()
482-
call assert_equal(0, bufexists('does_not_exist'))
483-
call assert_equal(1, bufexists(bufnr('%')))
484-
call assert_equal(0, bufexists(0))
485-
new Xfoo
486-
let bn = bufnr('%')
487-
call assert_equal(1, bufexists(bn))
488-
call assert_equal(1, bufexists('Xfoo'))
489-
call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
490-
call assert_equal(1, bufexists(0))
491-
bw
492-
call assert_equal(0, bufexists(bn))
493-
call assert_equal(0, bufexists('Xfoo'))
494-
endfunc
495-
496510
func Test_last_buffer_nr()
497511
call assert_equal(bufnr('$'), last_buffer_nr())
498512
endfunc

src/version.c

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

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1311,
774776
/**/
775777
1310,
776778
/**/

0 commit comments

Comments
 (0)