aboutsummaryrefslogtreecommitdiff
path: root/test/unit/mbyte_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/mbyte_spec.lua')
-rw-r--r--test/unit/mbyte_spec.lua27
1 files changed, 20 insertions, 7 deletions
diff --git a/test/unit/mbyte_spec.lua b/test/unit/mbyte_spec.lua
index 9b2415a93f..3e65537270 100644
--- a/test/unit/mbyte_spec.lua
+++ b/test/unit/mbyte_spec.lua
@@ -1,9 +1,11 @@
-local helpers = require("test.unit.helpers")
+local helpers = require("test.unit.helpers")(after_each)
+local itp = helpers.gen_itp(it)
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()
@@ -26,7 +28,7 @@ describe('mbyte', function()
before_each(function()
end)
- it('utf_ptr2char', function()
+ itp('utf_ptr2char', function()
-- For strings with length 1 the first byte is returned.
for c = 0, 255 do
eq(c, mbyte.utf_ptr2char(to_string({c, 0})))
@@ -41,10 +43,21 @@ describe('mbyte', function()
-- Sequences with more than four bytes
end)
+ for n = 0, 0xF do
+ itp(('utf_char2bytes for chars 0x%x - 0x%x'):format(n * 0x1000, n * 0x1000 + 0xFFF), function()
+ local char_p = ffi.typeof('char[?]')
+ for c = n * 0x1000, n * 0x1000 + 0xFFF 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)
+ end
describe('utfc_ptr2char_len', function()
- it('1-byte sequences', function()
+ itp('1-byte sequences', function()
local pcc = to_intp()
for c = 0, 255 do
eq(c, mbyte.utfc_ptr2char_len(to_string({c}), pcc, 1))
@@ -52,7 +65,7 @@ describe('mbyte', function()
end
end)
- it('2-byte sequences', function()
+ itp('2-byte sequences', function()
local pcc = to_intp()
-- No combining characters
eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x7f}), pcc, 2))
@@ -76,7 +89,7 @@ describe('mbyte', function()
eq(0, pcc[0])
end)
- it('3-byte sequences', function()
+ itp('3-byte sequences', function()
local pcc = to_intp()
-- No second UTF-8 character
@@ -108,7 +121,7 @@ describe('mbyte', function()
eq(0, pcc[0])
end)
- it('4-byte sequences', function()
+ itp('4-byte sequences', function()
local pcc = to_intp()
-- No following combining character
@@ -145,7 +158,7 @@ describe('mbyte', function()
eq(0, pcc[0])
end)
- it('5+-byte sequences', function()
+ itp('5+-byte sequences', function()
local pcc = to_intp()
-- No following combining character