aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_encodings_spec.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
committerWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
commitf9ead37d008e58daf1e3263298cfd4a1ab54d09c (patch)
treeb5cd2d09f0ee7e1e9e13feec26defe4f7d9f5003 /spec/util_encodings_spec.lua
parent2547ccfe3d26fbf57e0ecddf5cfd5d21377c3633 (diff)
downloadprosody-f9ead37d008e58daf1e3263298cfd4a1ab54d09c.tar.gz
prosody-f9ead37d008e58daf1e3263298cfd4a1ab54d09c.zip
Port tests to the `busted` test runner
Diffstat (limited to 'spec/util_encodings_spec.lua')
-rw-r--r--spec/util_encodings_spec.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/util_encodings_spec.lua b/spec/util_encodings_spec.lua
new file mode 100644
index 00000000..f67b5a00
--- /dev/null
+++ b/spec/util_encodings_spec.lua
@@ -0,0 +1,22 @@
+
+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);