1" Tests for setbufline() and getbufline() 2 3source shared.vim 4 5func Test_setbufline_getbufline() 6 new 7 let b = bufnr('%') 8 hide 9 call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) 10 call assert_equal(['foo'], getbufline(b, 1)) 11 call assert_equal(['bar'], getbufline(b, 2)) 12 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) 13 exe "bd!" b 14 call assert_equal([], getbufline(b, 1, 2)) 15 16 split Xtest 17 call setline(1, ['a', 'b', 'c']) 18 let b = bufnr('%') 19 wincmd w 20 call assert_equal(1, setbufline(b, 5, ['x'])) 21 call assert_equal(1, setbufline(1234, 1, ['x'])) 22 call assert_equal(0, setbufline(b, 4, ['d', 'e'])) 23 call assert_equal(['c'], getbufline(b, 3)) 24 call assert_equal(['d'], getbufline(b, 4)) 25 call assert_equal(['e'], getbufline(b, 5)) 26 call assert_equal([], getbufline(b, 6)) 27 exe "bwipe! " . b 28endfunc 29 30func Test_setline_startup() 31 let cmd = GetVimCommand('Xscript') 32 if cmd == '' 33 return 34 endif 35 call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript') 36 call system(cmd) 37 call assert_equal(['Hello'], readfile('Xtest')) 38 39 call delete('Xscript') 40 call delete('Xtest') 41endfunc 42