mirror of
https://github.com/denoland/deno.git
synced 2024-12-29 10:39:10 -05:00
1956cb8137
Fixes #6094 Fixes #4794
33 lines
856 B
TypeScript
33 lines
856 B
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
|
import { decode, encode } from "./base64url.ts";
|
|
|
|
const testsetString = [
|
|
["", ""],
|
|
["ß", "w58"],
|
|
["f", "Zg"],
|
|
["fo", "Zm8"],
|
|
["foo", "Zm9v"],
|
|
["foob", "Zm9vYg"],
|
|
["fooba", "Zm9vYmE"],
|
|
["foobar", "Zm9vYmFy"],
|
|
[">?>d?ß", "Pj8-ZD_Dnw"],
|
|
];
|
|
|
|
const testsetBinary = testsetString.map(([str, b64]) => [
|
|
new TextEncoder().encode(str),
|
|
b64,
|
|
]) as Array<[Uint8Array, string]>;
|
|
|
|
Deno.test("[encoding/base64url] testBase64urlEncodeBinary", () => {
|
|
for (const [input, output] of testsetBinary) {
|
|
assertEquals(encode(input), output);
|
|
}
|
|
});
|
|
|
|
Deno.test("[decoding/base64url] testBase64urlDecodeBinary", () => {
|
|
for (const [input, output] of testsetBinary) {
|
|
assertEquals(decode(output), input);
|
|
}
|
|
});
|