diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2022-08-30 23:23:09 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2022-08-30 23:23:09 -0600 |
commit | 968aa6e3ed0497ea99f123c74c5fd0f3880ccc63 (patch) | |
tree | 32ac91852b82d040012d40a3f54f772723509968 /test/functional/lua/vim_spec.lua | |
parent | 242f75745009b3a0a2108d98ce6c02b6e13aac3f (diff) | |
parent | f4274d0f62625683486d3912dcd6e8e45877c6a4 (diff) | |
download | rneovim-968aa6e3ed0497ea99f123c74c5fd0f3880ccc63.tar.gz rneovim-968aa6e3ed0497ea99f123c74c5fd0f3880ccc63.tar.bz2 rneovim-968aa6e3ed0497ea99f123c74c5fd0f3880ccc63.zip |
Merge remote-tracking branch 'upstream/master' into userreg
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 33 |
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() |