From 224d7df6309319cfa1f98aad3aa93c5b63ee4145 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 7 Mar 2016 07:37:21 +0300 Subject: eval/decode: Make sure that blank input does not crash Neovim --- test/functional/eval/json_functions_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/eval/json_functions_spec.lua') diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index 7ec3882a58..aa36b62757 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -451,6 +451,19 @@ describe('json_decode() function', function() it('parses U+00C3 correctly', function() eq('\xC3\x83', funcs.json_decode('"\xC3\x83"')) end) + + it('fails to parse empty string', function() + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode("")')) + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode(" ")')) + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode("\\t")')) + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode("\\n")')) + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode(" \\t\\n \\n\\t\\t \\n\\t\\n \\n \\t\\n\\t ")')) + end) end) describe('json_encode() function', function() -- cgit