Bram Moolenaar | b31cf2b | 2017-09-02 19:45:19 +0200 | [diff] [blame] | 1 | " Tests for setbufline() and getbufline() |
| 2 | |
| 3 | func Test_setbufline_getbufline() |
| 4 | new |
| 5 | let b = bufnr('%') |
| 6 | hide |
| 7 | call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) |
| 8 | call assert_equal(['foo'], getbufline(b, 1)) |
| 9 | call assert_equal(['bar'], getbufline(b, 2)) |
| 10 | call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) |
| 11 | exe "bd!" b |
| 12 | call assert_equal([], getbufline(b, 1, 2)) |
| 13 | |
| 14 | split Xtest |
| 15 | call setline(1, ['a', 'b', 'c']) |
| 16 | let b = bufnr('%') |
| 17 | wincmd w |
| 18 | call assert_equal(1, setbufline(b, 5, ['x'])) |
| 19 | call assert_equal(1, setbufline(1234, 1, ['x'])) |
| 20 | call assert_equal(0, setbufline(b, 4, ['d', 'e'])) |
| 21 | call assert_equal(['c'], getbufline(b, 3)) |
| 22 | call assert_equal(['d'], getbufline(b, 4)) |
| 23 | call assert_equal(['e'], getbufline(b, 5)) |
| 24 | call assert_equal([], getbufline(b, 6)) |
| 25 | exe "bwipe! " . b |
| 26 | endfunc |