2024-08-22 05:02:36 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
import { assertEquals } from "@std/assert";
|
2024-09-12 06:31:01 +00:00
|
|
|
import { encodeBase32Hex } from "./unstable_base32hex.ts";
|
2024-08-22 05:02:36 +00:00
|
|
|
import {
|
|
|
|
Base32HexDecoderStream,
|
|
|
|
Base32HexEncoderStream,
|
2024-09-12 05:45:35 +00:00
|
|
|
} from "./unstable_base32hex_stream.ts";
|
2024-08-22 05:02:36 +00:00
|
|
|
import { RandomSliceStream } from "./_random_slice_stream.ts";
|
|
|
|
import { toText } from "@std/streams/to-text";
|
|
|
|
import { concat } from "@std/bytes/concat";
|
|
|
|
|
|
|
|
Deno.test("Base32EncoderStream() encodes stream", async () => {
|
|
|
|
const stream = (await Deno.open("./deno.lock"))
|
|
|
|
.readable
|
|
|
|
.pipeThrough(new RandomSliceStream())
|
|
|
|
.pipeThrough(new Base32HexEncoderStream());
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
await toText(stream),
|
|
|
|
encodeBase32Hex(await Deno.readFile("./deno.lock")),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.test("Base32DecoderStream() decodes stream", async () => {
|
|
|
|
const stream = (await Deno.open("./deno.lock"))
|
|
|
|
.readable
|
|
|
|
.pipeThrough(new Base32HexEncoderStream())
|
|
|
|
.pipeThrough(new RandomSliceStream())
|
|
|
|
.pipeThrough(new Base32HexDecoderStream());
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
concat(await Array.fromAsync(stream)),
|
|
|
|
await Deno.readFile("./deno.lock"),
|
|
|
|
);
|
|
|
|
});
|