-
Notifications
You must be signed in to change notification settings - Fork 570
/
read_all_test.ts
28 lines (25 loc) · 964 Bytes
/
read_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
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../testing/asserts.ts";
import { Buffer } from "../io/buffer.ts";
import { readAll, readAllSync } from "./read_all.ts";
import { init } from "./_test_common.ts";
Deno.test("testReadAll", async () => {
const testBytes = init();
assert(testBytes);
const reader = new Buffer(testBytes.buffer);
const actualBytes = await readAll(reader);
assertEquals(testBytes.byteLength, actualBytes.byteLength);
for (let i = 0; i < testBytes.length; ++i) {
assertEquals(testBytes[i], actualBytes[i]);
}
});
Deno.test("testReadAllSync", () => {
const testBytes = init();
assert(testBytes);
const reader = new Buffer(testBytes.buffer);
const actualBytes = readAllSync(reader);
assertEquals(testBytes.byteLength, actualBytes.byteLength);
for (let i = 0; i < testBytes.length; ++i) {
assertEquals(testBytes[i], actualBytes[i]);
}
});