diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-06 21:04:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-06 21:04:07 +0200 |
commit | ca851593a660f08aba5c134f90c238d4a3e983e6 (patch) | |
tree | 363e4fc7ee646a53d869cb941e09feadc0dd46dc /src/testdir/test_bufline.vim | |
parent | 891e1fd894720d0b99a9daefa41e8181844f819a (diff) |
patch 8.1.0037: cannot easily append lines to another bufferv8.1.0037
Problem: Cannot easily append lines to another buffer.
Solution: Add appendbufline().
Diffstat (limited to 'src/testdir/test_bufline.vim')
-rw-r--r-- | src/testdir/test_bufline.vim | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index b886e99506..b110c44eb1 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -1,4 +1,4 @@ -" Tests for setbufline() and getbufline() +" Tests for setbufline(), getbufline(), appendbufline() source shared.vim @@ -65,3 +65,28 @@ func Test_setline_startup() call delete('Xscript') call delete('Xtest') endfunc + +func Test_appendbufline() + new + let b = bufnr('%') + hide + call assert_equal(0, appendbufline(b, 0, ['foo', 'bar'])) + call assert_equal(['foo'], getbufline(b, 1)) + call assert_equal(['bar'], getbufline(b, 2)) + call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) + exe "bd!" b + call assert_equal([], getbufline(b, 1, 2)) + + split Xtest + call setline(1, ['a', 'b', 'c']) + let b = bufnr('%') + wincmd w + call assert_equal(1, appendbufline(b, 4, ['x'])) + call assert_equal(1, appendbufline(1234, 1, ['x'])) + call assert_equal(0, appendbufline(b, 3, ['d', 'e'])) + call assert_equal(['c'], getbufline(b, 3)) + call assert_equal(['d'], getbufline(b, 4)) + call assert_equal(['e'], getbufline(b, 5)) + call assert_equal([], getbufline(b, 6)) + exe "bwipe! " . b +endfunc |