diff --git a/spec/test/utilSpec.js b/spec/test/utilSpec.js --- a/spec/test/utilSpec.js +++ b/spec/test/utilSpec.js @@ -13,6 +13,15 @@ describe("Util",function(){ ["\uD55C\uAD6D\uC5B4",[0xED,0x95,0x9C,0xEA,0xB5,0xAD,0xEC,0x96,0xB4]], ["\ud84c\udfb4",[0xf0,0xa3,0x8e,0xb4]] ]; + let base64=[ + [[],""], + [[102],"Zg=="], + [[102,111],"Zm8="], + [[102,111,111],"Zm9v"], + [[102,111,111,98],"Zm9vYg=="], + [[102,111,111,98,97],"Zm9vYmE="], + [[102,111,111,98,97,114],"Zm9vYmFy"] + ]; describe("bytes2int32s",function(){ it("should pack bytes into 32b integers",function(){ @@ -34,4 +43,17 @@ describe("Util",function(){ utf.forEach(couple=>expect(util.utf82str(couple[1])).toEqual(couple[0])); }); }); + + + describe("bytes2base64",function(){ + it("should correctly encode bytes into base64",function(){ + base64.forEach(couple=>expect(util.bytes2base64(couple[0])).toEqual(couple[1])); + }); + }); + + describe("base642bytes",function(){ + it("should correctly decode bytes from base64",function(){ + base64.forEach(couple=>expect(util.base642bytes(couple[1])).toEqual(couple[0])); + }); + }); });