aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/json_functions_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-03-07 07:37:21 +0300
committerZyX <kp-pav@yandex.ru>2016-04-18 02:48:20 +0300
commit224d7df6309319cfa1f98aad3aa93c5b63ee4145 (patch)
treeb9f58278536ecaa67e3e15fb145b7b7e23da4065 /test/functional/eval/json_functions_spec.lua
parent394830631f130ad646f23358bf7863e7a37c6d78 (diff)
downloadrneovim-224d7df6309319cfa1f98aad3aa93c5b63ee4145.tar.gz
rneovim-224d7df6309319cfa1f98aad3aa93c5b63ee4145.tar.bz2
rneovim-224d7df6309319cfa1f98aad3aa93c5b63ee4145.zip
eval/decode: Make sure that blank input does not crash Neovim
Diffstat (limited to 'test/functional/eval/json_functions_spec.lua')
-rw-r--r--test/functional/eval/json_functions_spec.lua13
1 files changed, 13 insertions, 0 deletions
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()