IMPORTANT: due to a drive failure, as of 13-Mar-2021, the Mercurial repository had to be re-mirrored, which changed every commit SHA. The old SHAs and trees are backed up in the vault branches. Please migrate to the new branches as soon as you can.
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.
 
 
 
 
prosody/tests/test_utf8.lua

18 lines
639 B

package.cpath = "../?.so"
package.path = "../?.lua";
function valid()
local encodings = require "util.encodings";
local utf8 = assert(encodings.utf8, "no encodings.utf8 module");
for line in io.lines("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+):");
if expect ~= "pass" and expect ~= "fail" then
error("unknown expectation: "..line:match("^[^:]+"));
end
local valid = utf8.valid(data);
assert_equal(valid, utf8.valid(data.." "));
assert_equal(valid, expect == "pass", line);
end
end