blob: f02afecc85fbd211adf346c4491fca33b834bd78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package.path = "../?.lua" .. package.path
-- This unittest file only makes sure that extremely trivial things do not break. It is not intended to be complete
local tr = require("textrender")
describe("string to unicode codepoint sequence converter", function()
local mbstoucs = tr.mbstoucs
it("should convert strings properly", function()
assert.same({0x61,0xe9,0x01d8}, mbstoucs("aéǘ"))
end)
it("should not convert invalid multibyte sequences", function()
local function assert_invalid(...)
assert.same({}, mbstoucs(string.char(...)))
end
assert_invalid(65, math.random(128,191), math.random(128,191))
assert_invalid(65, math.random(192,223))
end)
end)
|