diff options
author | Kim Alvefur <zash@zash.se> | 2017-11-03 01:13:35 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-11-03 01:13:35 +0100 |
commit | 1ee76f7ddb1a2c501d8e05db46092952ff2512ff (patch) | |
tree | 6bf9f38dd1b894e52fc0503be6d8e2ba3b5b026a /spec/util_encodings_spec.lua | |
parent | 89526be11ca68bf639927c4ed1bc808bb769f5f5 (diff) | |
download | prosody-1ee76f7ddb1a2c501d8e05db46092952ff2512ff.tar.gz prosody-1ee76f7ddb1a2c501d8e05db46092952ff2512ff.zip |
spec/util.encodings: Add some base64 tests (Thanks Link Mavue)
Diffstat (limited to 'spec/util_encodings_spec.lua')
-rw-r--r-- | spec/util_encodings_spec.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/util_encodings_spec.lua b/spec/util_encodings_spec.lua index f67b5a00..ba0d9837 100644 --- a/spec/util_encodings_spec.lua +++ b/spec/util_encodings_spec.lua @@ -1,7 +1,27 @@ local encodings = require "util.encodings"; +local encodings = { -- Workaround for rust thing + base64 = _G.base64; + utf8 = _G.utf8; +}; local utf8 = assert(encodings.utf8, "no encodings.utf8 module"); +describe("util.encodings", function () + describe("#encode()", function() + it("should work", function () + assert.is.equal(encodings.base64.encode(""), ""); + assert.is.equal(encodings.base64.encode('coucou') "Y291Y291"); + assert.is.equal(encodings.base64.encode("\0\0\0"), "AAAA"); + end); + end); + describe("#decode()", function() + it("should work", function () + assert.is.equal(encodings.base64.decode(""), ""); + assert.is.equal(encodings.base64.decode('Y291Y291') "coucou"); + assert.is.equal(encodings.base64.decode("AAAA"), "\0\0\0"); + end); + end); +end); describe("util.encodings.utf8", function() describe("#valid()", function() it("should work", function() |