aboutsummaryrefslogtreecommitdiff
path: root/advtrains/spec/textrender_spec.lua
blob: 063d9ee2030750680204894cc62041c6477a56eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package.path = "../?.lua" .. package.path

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)