functests: Test for “string cannot contain newline” set_lines error

Should make me able to determine whether they are lua bindings that contain 
a bug or set_lines.
This commit is contained in:
ZyX 2017-04-11 02:24:37 +03:00
parent 0c5e359cb5
commit add76592d9

View File

@ -10,6 +10,7 @@ local insert = helpers.insert
local NIL = helpers.NIL
local meth_pcall = helpers.meth_pcall
local command = helpers.command
local bufmeths = helpers.bufmeths
describe('api/buf', function()
before_each(clear)
@ -121,6 +122,15 @@ describe('api/buf', function()
local get_lines, set_lines = curbufmeths.get_lines, curbufmeths.set_lines
local line_count = curbufmeths.line_count
it('fails correctly when input is not valid', function()
eq(1, curbufmeths.get_number())
local err, emsg = pcall(bufmeths.set_lines, 1, 1, 2, false, {'b\na'})
eq(false, err)
local exp_emsg = 'string cannot contain newlines'
-- Expected {filename}:{lnum}: {exp_emsg}
eq(': ' .. exp_emsg, emsg:sub(-#exp_emsg - 2))
end)
it('has correct line_count when inserting and deleting', function()
eq(1, line_count())
set_lines(-1, -1, true, {'line'})