Comparison

spec/util_encodings_spec.lua @ 8236:4878e4159e12

Port tests to the `busted` test runner
author Waqas Hussain <waqas20@gmail.com>
date Fri, 15 Sep 2017 17:07:57 -0400
child 8367:60eb22fd21b8
comparison
equal deleted inserted replaced
8235:7d9a2c200736 8236:4878e4159e12
1
2 local encodings = require "util.encodings";
3 local utf8 = assert(encodings.utf8, "no encodings.utf8 module");
4
5 describe("util.encodings.utf8", function()
6 describe("#valid()", function()
7 it("should work", function()
8
9 for line in io.lines("spec/utf8_sequences.txt") do
10 local data = line:match(":%s*([^#]+)"):gsub("%s+", ""):gsub("..", function (c) return string.char(tonumber(c, 16)); end)
11 local expect = line:match("(%S+):");
12
13 assert(expect == "pass" or expect == "fail", "unknown expectation: "..line:match("^[^:]+"));
14
15 local valid = utf8.valid(data);
16 assert.is.equal(valid, utf8.valid(data.." "));
17 assert.is.equal(valid, expect == "pass", line);
18 end
19
20 end);
21 end);
22 end);