From 460843b4cd5f2bceaeac1dbc165c416b272793ed Mon Sep 17 00:00:00 2001 From: Scott Prager Date: Fri, 24 Oct 2014 14:23:17 -0400 Subject: api: Handle NULs and newlines in buffer_*_line. --- test/functional/api/buffer_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 169d605b63..b85594f7af 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -34,6 +34,11 @@ describe('buffer_* functions', function() curbuf('del_line', 0) eq('', curbuf('get_line', 0)) end) + + it('can handle NULs', function() + curbuf('set_line', 0, 'ab\0cd') + eq('ab\0cd', curbuf('get_line', 0)) + end) end) -- cgit From cea5092f40610216a83b6ab0a56d94295ce1e88a Mon Sep 17 00:00:00 2001 From: Scott Prager Date: Fri, 24 Oct 2014 16:36:30 -0400 Subject: api: Add tests for when not to handle NULs. --- test/functional/api/vim_spec.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index f34df8cefb..2c17a2acd0 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -36,6 +36,10 @@ describe('vim_* functions', function() -- 19 * 2 (each japanese character occupies two cells) eq(44, nvim('strwidth', 'neovimのデザインかなりまともなのになってる。')) end) + + it('cannot handle NULs', function() + eq(0, nvim('strwidth', '\0abc')) + end) end) describe('{get,set}_current_line', function() @@ -52,6 +56,11 @@ describe('vim_* functions', function() eq({1, 2, {['3'] = 1}}, nvim('get_var', 'lua')) eq({1, 2, {['3'] = 1}}, nvim('eval', 'g:lua')) end) + + it('truncates values with NULs in them', function() + nvim('set_var', 'xxx', 'ab\0cd') + eq('ab', nvim('get_var', 'xxx')) + end) end) describe('{get,set}_option', function() -- cgit