summaryrefslogtreecommitdiff
path: root/js/buffer_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-03-28 04:29:36 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-27 23:29:36 -0400
commit597ee38ef28d040cbf4d629cf3d2bd3e89a70a11 (patch)
treeed376d8951cd986beddf6a96341cbf47a2d22a11 /js/buffer_test.ts
parentd0b6152f11800b0baac1ae68d2eef7bfcea13cb5 (diff)
Rewrite readFile and writeFile (#2000)
Using open/read/write
Diffstat (limited to 'js/buffer_test.ts')
-rw-r--r--js/buffer_test.ts29
1 files changed, 28 insertions, 1 deletions
diff --git a/js/buffer_test.ts b/js/buffer_test.ts
index 90e171330..f07d9d65d 100644
--- a/js/buffer_test.ts
+++ b/js/buffer_test.ts
@@ -5,7 +5,7 @@
// https://github.com/golang/go/blob/master/LICENSE
import { assertEquals, test } from "./test_util.ts";
-const { Buffer, readAll } = Deno;
+const { Buffer, readAll, readAllSync } = Deno;
type Buffer = Deno.Buffer;
// N controls how many iterations of certain checks are performed.
@@ -193,6 +193,23 @@ test(async function bufferReadFrom() {
}
});
+test(async function bufferReadFromSync() {
+ init();
+ const buf = new Buffer();
+ for (let i = 3; i < 30; i += 3) {
+ const s = await fillBytes(
+ buf,
+ "",
+ 5,
+ testBytes.subarray(0, Math.floor(testBytes.byteLength / i))
+ );
+ const b = new Buffer();
+ b.readFromSync(buf);
+ const fub = new Uint8Array(testString.length);
+ await empty(b, s, fub);
+ }
+});
+
test(async function bufferTestGrow() {
const tmp = new Uint8Array(72);
for (let startLen of [0, 100, 1000, 10000, 100000]) {
@@ -226,3 +243,13 @@ test(async function testReadAll() {
assertEquals(testBytes[i], actualBytes[i]);
}
});
+
+test(function testReadAllSync() {
+ init();
+ const reader = new Buffer(testBytes.buffer as ArrayBuffer);
+ const actualBytes = readAllSync(reader);
+ assertEquals(testBytes.byteLength, actualBytes.byteLength);
+ for (let i = 0; i < testBytes.length; ++i) {
+ assertEquals(testBytes[i], actualBytes[i]);
+ }
+});