-
Notifications
You must be signed in to change notification settings - Fork 603
/
write_all_test.ts
30 lines (27 loc) · 997 Bytes
/
write_all_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../testing/asserts.ts";
import { writeAll, writeAllSync } from "./write_all.ts";
import { Buffer } from "../io/buffer.ts";
import { init } from "./_test_common.ts";
Deno.test("testwriteAll", async () => {
const testBytes = init();
assert(testBytes);
const writer = new Buffer();
await writeAll(writer, testBytes);
const actualBytes = writer.bytes();
assertEquals(testBytes.byteLength, actualBytes.byteLength);
for (let i = 0; i < testBytes.length; ++i) {
assertEquals(testBytes[i], actualBytes[i]);
}
});
Deno.test("testWriteAllSync", () => {
const testBytes = init();
assert(testBytes);
const writer = new Buffer();
writeAllSync(writer, testBytes);
const actualBytes = writer.bytes();
assertEquals(testBytes.byteLength, actualBytes.byteLength);
for (let i = 0; i < testBytes.length; ++i) {
assertEquals(testBytes[i], actualBytes[i]);
}
});