comparison src/testdir/test_functions.vim @ 12869:a89350ba2a9d v8.0.1311

patch 8.0.1311: no test for strpart() commit https://github.com/vim/vim/commit/c7d16dce2f180c8ebfc8105ad090b0ea2deedcdc Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 18 20:32:03 2017 +0100 patch 8.0.1311: no test for strpart() Problem: No test for strpart(). Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/2347)
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Nov 2017 20:45:05 +0100
parents 61450cb2b6a1
children 17720967656c
comparison
equal deleted inserted replaced
12868:029c42326ffb 12869:a89350ba2a9d
1 " Tests for various functions. 1 " Tests for various functions.
2
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
2 18
3 func Test_empty() 19 func Test_empty()
4 call assert_equal(1, empty('')) 20 call assert_equal(1, empty(''))
5 call assert_equal(0, empty('a')) 21 call assert_equal(0, empty('a'))
6 22
164 180
165 call assert_fails('call simplify({->0})', 'E729:') 181 call assert_fails('call simplify({->0})', 'E729:')
166 call assert_fails('call simplify([])', 'E730:') 182 call assert_fails('call simplify([])', 'E730:')
167 call assert_fails('call simplify({})', 'E731:') 183 call assert_fails('call simplify({})', 'E731:')
168 call assert_fails('call simplify(1.2)', 'E806:') 184 call assert_fails('call simplify(1.2)', 'E806:')
185 endfunc
186
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
169 endfunc 198 endfunc
170 199
171 func Test_tolower() 200 func Test_tolower()
172 call assert_equal("", tolower("")) 201 call assert_equal("", tolower(""))
173 202
476 close 505 close
477 506
478 set fileformats& 507 set fileformats&
479 endfunc 508 endfunc
480 509
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
496 func Test_last_buffer_nr() 510 func Test_last_buffer_nr()
497 call assert_equal(bufnr('$'), last_buffer_nr()) 511 call assert_equal(bufnr('$'), last_buffer_nr())
498 endfunc 512 endfunc
499 513
500 func Test_stridx() 514 func Test_stridx()