std/io/multi_reader_test.ts
Yoshiya Hinosawa 0ce9c2bf7e
experiment
2024-01-31 18:10:15 +09:00

19 lines
661 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "@std/assert";
import { MultiReader } from "./multi_reader.ts";
import { StringWriter } from "./string_writer.ts";
import { copyN } from "./copy_n.ts";
import { copy } from "./copy.ts";
import { StringReader } from "./string_reader.ts";
Deno.test("ioMultiReader", async function () {
const r = new MultiReader([new StringReader("abc"), new StringReader("def")]);
const w = new StringWriter();
const n = await copyN(r, w, 4);
assertEquals(n, 4);
assertEquals(w.toString(), "abcd");
await copy(r, w);
assertEquals(w.toString(), "abcdef");
});