diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-11-01 19:15:43 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-11-01 22:00:40 +0100 |
commit | c40f992e10355edd586d5cfbca246b9659554438 (patch) | |
tree | 7411e57a18710d161c5d48aee37eaa59fbd8e960 /test/functional/api/buffer_spec.lua | |
parent | 88f77c28e52a17e76f226beded0c66a018f0540d (diff) | |
download | rneovim-c40f992e10355edd586d5cfbca246b9659554438.tar.gz rneovim-c40f992e10355edd586d5cfbca246b9659554438.tar.bz2 rneovim-c40f992e10355edd586d5cfbca246b9659554438.zip |
api: simplify nvim_buf_get_offset function
Diffstat (limited to 'test/functional/api/buffer_spec.lua')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index d3739c74d2..d9412f0f13 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -301,37 +301,40 @@ describe('api/buf', function() end) end) - describe('get_offset_for_line', function() - local get_offset_for_line = curbufmeths.get_offset_for_line + describe('get_offset', function() + local get_offset = curbufmeths.get_offset it('works', function() - curbufmeths.set_lines(0,-1,true,{'Some','exa\000mple', '', 'text'}) - eq(4, curbufmeths.line_count()) - eq(0, get_offset_for_line(0)) - eq(5, get_offset_for_line(1)) - eq(14, get_offset_for_line(2)) - eq(15, get_offset_for_line(3)) - eq(20, get_offset_for_line(4)) - eq({false,'Index out of bounds'}, meth_pcall(get_offset_for_line, 5)) - eq({false,'Index out of bounds'}, meth_pcall(get_offset_for_line, -1)) + curbufmeths.set_lines(0,-1,true,{'Some\r','exa\000mple', '', 'buf\rfer', 'text'}) + eq(5, curbufmeths.line_count()) + eq(0, get_offset(0)) + eq(6, get_offset(1)) + eq(15, get_offset(2)) + eq(16, get_offset(3)) + eq(24, get_offset(4)) + eq(29, get_offset(5)) + eq({false,'Index out of bounds'}, meth_pcall(get_offset, 6)) + eq({false,'Index out of bounds'}, meth_pcall(get_offset, -1)) curbufmeths.set_option('eol', false) curbufmeths.set_option('fixeol', false) - eq(19, get_offset_for_line(4)) + eq(28, get_offset(5)) + -- fileformat is ignored curbufmeths.set_option('fileformat', 'dos') - eq(0, get_offset_for_line(0)) - eq(6, get_offset_for_line(1)) - eq(16, get_offset_for_line(2)) - eq(18, get_offset_for_line(3)) - eq(22, get_offset_for_line(4)) + eq(0, get_offset(0)) + eq(6, get_offset(1)) + eq(15, get_offset(2)) + eq(16, get_offset(3)) + eq(24, get_offset(4)) + eq(28, get_offset(5)) curbufmeths.set_option('eol', true) - eq(24, get_offset_for_line(4)) + eq(29, get_offset(5)) command("set hidden") command("enew") - eq(6, bufmeths.get_offset_for_line(1,1)) + eq(6, bufmeths.get_offset(1,1)) command("bunload! 1") - eq(-1, bufmeths.get_offset_for_line(1,1)) + eq(-1, bufmeths.get_offset(1,1)) end) end) |