diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-26 23:26:04 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-01 08:45:19 -0400 |
commit | 3e4a058b01db779e087eaf97826cee545de2a923 (patch) | |
tree | 34776ed9d7465f43a4692ebb4187b3030312bade /test/unit/mbyte_spec.lua | |
parent | 6ff892165a6e3edd20ce31ba7c9a4af458684aca (diff) | |
download | rneovim-3e4a058b01db779e087eaf97826cee545de2a923.tar.gz rneovim-3e4a058b01db779e087eaf97826cee545de2a923.tar.bz2 rneovim-3e4a058b01db779e087eaf97826cee545de2a923.zip |
test: port kword_test to Lua for utf_char2bytes()
Use LuaJIT FFI to create char pointer.
Validate output with utf_ptr2char(), vim_iswordc() and vim_iswordp().
Use const for LuaJIT string-to-char conversion.
Diffstat (limited to 'test/unit/mbyte_spec.lua')
-rw-r--r-- | test/unit/mbyte_spec.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/unit/mbyte_spec.lua b/test/unit/mbyte_spec.lua index 6feef4e601..1e7e9fd6e6 100644 --- a/test/unit/mbyte_spec.lua +++ b/test/unit/mbyte_spec.lua @@ -5,6 +5,7 @@ local ffi = helpers.ffi local eq = helpers.eq local mbyte = helpers.cimport("./src/nvim/mbyte.h") +local charset = helpers.cimport('./src/nvim/charset.h') describe('mbyte', function() @@ -42,6 +43,15 @@ describe('mbyte', function() -- Sequences with more than four bytes end) + itp('utf_char2bytes', function() + local char_p = ffi.typeof('char[?]') + for c = 0, 0xFFFF do + local p = char_p(4, 0) + mbyte.utf_char2bytes(c, p) + eq(c, mbyte.utf_ptr2char(p)) + eq(charset.vim_iswordc(c), charset.vim_iswordp(p)) + end + end) describe('utfc_ptr2char_len', function() |