mirror of https://github.com/bjc/prosody
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
706 B
22 lines
706 B
|
|
local encodings = require "util.encodings";
|
|
local utf8 = assert(encodings.utf8, "no encodings.utf8 module");
|
|
|
|
describe("util.encodings.utf8", function()
|
|
describe("#valid()", function()
|
|
it("should work", function()
|
|
|
|
for line in io.lines("spec/utf8_sequences.txt") do
|
|
local data = line:match(":%s*([^#]+)"):gsub("%s+", ""):gsub("..", function (c) return string.char(tonumber(c, 16)); end)
|
|
local expect = line:match("(%S+):");
|
|
|
|
assert(expect == "pass" or expect == "fail", "unknown expectation: "..line:match("^[^:]+"));
|
|
|
|
local valid = utf8.valid(data);
|
|
assert.is.equal(valid, utf8.valid(data.." "));
|
|
assert.is.equal(valid, expect == "pass", line);
|
|
end
|
|
|
|
end);
|
|
end);
|
|
end);
|
|
|