aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-02 12:18:44 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-02 12:20:01 -0400
commit7b53b5380a911dd48af10ff06a4005476d728b0a (patch)
treec81f69b1b50418682ec0ed2c0ddd4cc1fe0054ae
parent1ef585d6dc530dfc9058ac49c980439d3a2c6a19 (diff)
downloadrneovim-7b53b5380a911dd48af10ff06a4005476d728b0a.tar.gz
rneovim-7b53b5380a911dd48af10ff06a4005476d728b0a.tar.bz2
rneovim-7b53b5380a911dd48af10ff06a4005476d728b0a.zip
vim-patch:8.0.1311: no test for strpart()
Problem: No test for strpart(). Solution: Add a test. (Dominique Pelle, closes vim/vim#2347) https://github.com/vim/vim/commit/c7d16dce2f180c8ebfc8105ad090b0ea2deedcdc
-rw-r--r--src/nvim/testdir/test_functions.vim44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index d34d4596d2..a2cdf71aa1 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -1,5 +1,21 @@
" Tests for various functions.
+" Must be done first, since the alternate buffer must be unset.
+func Test_00_bufexists()
+ call assert_equal(0, bufexists('does_not_exist'))
+ call assert_equal(1, bufexists(bufnr('%')))
+ call assert_equal(0, bufexists(0))
+ new Xfoo
+ let bn = bufnr('%')
+ call assert_equal(1, bufexists(bn))
+ call assert_equal(1, bufexists('Xfoo'))
+ call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
+ call assert_equal(1, bufexists(0))
+ bw
+ call assert_equal(0, bufexists(bn))
+ call assert_equal(0, bufexists('Xfoo'))
+endfunc
+
func Test_empty()
call assert_equal(1, empty(''))
call assert_equal(0, empty('a'))
@@ -199,6 +215,19 @@ func Test_setbufvar_options()
bwipe!
endfunc
+func Test_strpart()
+ call assert_equal('de', strpart('abcdefg', 3, 2))
+ call assert_equal('ab', strpart('abcdefg', -2, 4))
+ call assert_equal('abcdefg', strpart('abcdefg', -2))
+ call assert_equal('fg', strpart('abcdefg', 5, 4))
+ call assert_equal('defg', strpart('abcdefg', 3))
+
+ if has('multi_byte')
+ call assert_equal('lép', strpart('éléphant', 2, 4))
+ call assert_equal('léphant', strpart('éléphant', 2))
+ endif
+endfunc
+
func Test_tolower()
call assert_equal("", tolower(""))
@@ -505,21 +534,6 @@ func Test_getbufvar()
set fileformats&
endfunc
-func Test_bufexists()
- call assert_equal(0, bufexists('does_not_exist'))
- call assert_equal(1, bufexists(bufnr('%')))
- call assert_equal(0, bufexists(0))
- new Xfoo
- let bn = bufnr('%')
- call assert_equal(1, bufexists(bn))
- call assert_equal(1, bufexists('Xfoo'))
- call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
- call assert_equal(1, bufexists(0))
- bw
- call assert_equal(0, bufexists(bn))
- call assert_equal(0, bufexists('Xfoo'))
-endfunc
-
func Test_last_buffer_nr()
call assert_equal(bufnr('$'), last_buffer_nr())
endfunc