diff options
Diffstat (limited to 'std/encoding/base64_test.ts')
-rw-r--r-- | std/encoding/base64_test.ts | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/std/encoding/base64_test.ts b/std/encoding/base64_test.ts index 5fe89410b..65c62f4cd 100644 --- a/std/encoding/base64_test.ts +++ b/std/encoding/base64_test.ts @@ -1,9 +1,11 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + import { assertEquals } from "../testing/asserts.ts"; -import { decode, decodeString, encode } from "./base64.ts"; +import { decode, encode } from "./base64.ts"; const testsetString = [ ["", ""], + ["ß", "w58="], ["f", "Zg=="], ["fo", "Zm8="], ["foo", "Zm9v"], @@ -12,12 +14,10 @@ const testsetString = [ ["foobar", "Zm9vYmFy"], ]; -const testsetBinary = [ - [new TextEncoder().encode("\x00"), "AA=="], - [new TextEncoder().encode("\x00\x00"), "AAA="], - [new TextEncoder().encode("\x00\x00\x00"), "AAAA"], - [new TextEncoder().encode("\x00\x00\x00\x00"), "AAAAAA=="], -]; +const testsetBinary = testsetString.map(([str, b64]) => [ + new TextEncoder().encode(str), + b64, +]) as Array<[Uint8Array, string]>; Deno.test("[encoding/base64] testBase64EncodeString", () => { for (const [input, output] of testsetString) { @@ -25,21 +25,21 @@ Deno.test("[encoding/base64] testBase64EncodeString", () => { } }); -Deno.test("[encoding/base64] testBase64DecodeString", () => { - for (const [input, output] of testsetString) { - assertEquals(decodeString(output), input); +Deno.test("[encoding/base64] testBase64EncodeBinary", () => { + for (const [input, output] of testsetBinary) { + assertEquals(encode(input), output); } }); -Deno.test("[encoding/base64] testBase64EncodeBinary", () => { +Deno.test("[encoding/base64] testBase64EncodeBinaryBuffer", () => { for (const [input, output] of testsetBinary) { - assertEquals(encode(input), output); + assertEquals(encode(input.buffer), output); } }); Deno.test("[encoding/base64] testBase64DecodeBinary", () => { for (const [input, output] of testsetBinary) { - const outputBinary = new Uint8Array(decode(output as string)); - assertEquals(outputBinary, input as Uint8Array); + const outputBinary = decode(output); + assertEquals(outputBinary, input); } }); |