/* global expect */
describe("Util",function(){
let util=require("../../src/util.js");
let utf=[ // https://tools.ietf.org/html/rfc3629#page-8
["",[]],
["abc",[97,98,99]],
["å",[195,165]],
["🚅",[240,159,154,133]],
["žír",[0xc5,0xbe,0xc3,0xad,114]],
["A\u2262\u0391.",[0x41,0xE2,0x89,0xA2,0xCE,0x91,0x2E]],
["\uD55C\uAD6D\uC5B4",[0xED,0x95,0x9C,0xEA,0xB5,0xAD,0xEC,0x96,0xB4]],
["\ud84c\udfb4",[0xf0,0xa3,0x8e,0xb4]]
];
describe("str2utf8",function(){
it("should encode a String into bytes in UTF-8",function(){
utf.forEach(couple=>expect(util.str2utf8(couple[0])).toEqual(couple[1]));
});
});
describe("utf82str",function(){
it("should decode a String from UTF-8 bytes",function(){
utf.forEach(couple=>expect(util.utf82str(couple[1])).toEqual(couple[0]));
});
});
});