aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-08-24 14:41:31 +0100
committerGitHub <noreply@github.com>2022-08-24 14:41:31 +0100
commitb1eaa2b9a3bae46f6dcbab8dc3a84e0044b11317 (patch)
tree486a0a3f0118952157e38edad14f71ca16922a77 /test/functional/lua/vim_spec.lua
parent9be4bfc5f4951976131e5e99ecf05882f6767fb4 (diff)
downloadrneovim-b1eaa2b9a3bae46f6dcbab8dc3a84e0044b11317.tar.gz
rneovim-b1eaa2b9a3bae46f6dcbab8dc3a84e0044b11317.tar.bz2
rneovim-b1eaa2b9a3bae46f6dcbab8dc3a84e0044b11317.zip
feat(lua): add vim.iconv (#18286)
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 2b249b7a69..f2fb661b70 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -2721,6 +2721,39 @@ describe('lua stdlib', function()
]]
end)
end)
+
+ describe('vim.iconv', function()
+ it('can convert strings', function()
+ eq('hello', exec_lua[[
+ return vim.iconv('hello', 'latin1', 'utf-8')
+ ]])
+ end)
+
+ it('can validate arguments', function()
+ eq({false, 'Expected at least 3 arguments'}, exec_lua[[
+ return {pcall(vim.iconv, 'hello')}
+ ]])
+
+ eq({false, 'bad argument #3 to \'?\' (expected string)'}, exec_lua[[
+ return {pcall(vim.iconv, 'hello', 'utf-8', true)}
+ ]])
+ end)
+
+ it('can handle bad encodings', function()
+ eq(NIL, exec_lua[[
+ return vim.iconv('hello', 'foo', 'bar')
+ ]])
+ end)
+
+ it('can handle strings with NUL bytes', function()
+ eq(7, exec_lua[[
+ local a = string.char(97, 98, 99, 0, 100, 101, 102) -- abc\0def
+ return string.len(vim.iconv(a, 'latin1', 'utf-8'))
+ ]])
+ end)
+
+ end)
+
end)
describe('lua: builtin modules', function()