2019-03-06 19:42:24 -05:00
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2019-02-10 18:49:48 -05:00
|
|
|
import { StringWriter } from "./writers.ts";
|
|
|
|
import { StringReader } from "./readers.ts";
|
|
|
|
import { copyN } from "./ioutil.ts";
|
|
|
|
|
2020-06-12 15:23:38 -04:00
|
|
|
Deno.test("ioStringWriter", async function (): Promise<void> {
|
2019-02-10 18:49:48 -05:00
|
|
|
const w = new StringWriter("base");
|
|
|
|
const r = new StringReader("0123456789");
|
2020-04-26 16:26:02 -04:00
|
|
|
await copyN(r, w, 4);
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(w.toString(), "base0123");
|
2020-06-12 15:23:38 -04:00
|
|
|
await Deno.copy(r, w);
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(w.toString(), "base0123456789");
|
2019-02-10 18:49:48 -05:00
|
|
|
});
|
2020-06-12 15:15:29 -04:00
|
|
|
|
2020-06-12 18:10:25 -04:00
|
|
|
Deno.test("ioStringWriterSync", function (): void {
|
2020-06-12 15:15:29 -04:00
|
|
|
const encoder = new TextEncoder();
|
|
|
|
const w = new StringWriter("");
|
|
|
|
w.writeSync(encoder.encode("deno"));
|
|
|
|
assertEquals(w.toString(), "deno");
|
|
|
|
w.writeSync(encoder.encode("\nland"));
|
|
|
|
assertEquals(w.toString(), "deno\nland");
|
|
|
|
});
|