Changeset

8367:60eb22fd21b8

spec/util.encodings: Add some base64 tests (Thanks Link Mavue)
author Kim Alvefur <zash@zash.se>
date Fri, 03 Nov 2017 01:13:35 +0100
parents 8366:272ff3ab25f3
children 8369:e08a0ff6ce14
files spec/util_encodings_spec.lua
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/spec/util_encodings_spec.lua	Sun Oct 29 02:05:19 2017 +0200
+++ b/spec/util_encodings_spec.lua	Fri Nov 03 01:13:35 2017 +0100
@@ -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()