2019-03-06 19:42:24 -05:00
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2019-02-11 08:49:48 +09:00
|
|
|
import { StringWriter } from "./writers.ts";
|
|
|
|
import { StringReader } from "./readers.ts";
|
|
|
|
import { copyN } from "./ioutil.ts";
|
|
|
|
|
2020-06-12 20:23:38 +01:00
|
|
|
Deno.test("ioStringWriter", async function (): Promise<void> {
|
2019-02-11 08:49:48 +09:00
|
|
|
const w = new StringWriter("base");
|
|
|
|
const r = new StringReader("0123456789");
|
2020-04-27 01:56:02 +05:30
|
|
|
await copyN(r, w, 4);
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(w.toString(), "base0123");
|
2020-06-12 20:23:38 +01:00
|
|
|
await Deno.copy(r, w);
|
2019-03-06 19:42:24 -05:00
|
|
|
assertEquals(w.toString(), "base0123456789");
|
2019-02-11 08:49:48 +09:00
|
|
|
});
|
2020-06-12 21:15:29 +02:00
|
|
|
|
2020-06-13 00:10:25 +02:00
|
|
|
Deno.test("ioStringWriterSync", function (): void {
|
2020-06-12 21:15:29 +02: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");
|
|
|
|
});
|