From 597ee38ef28d040cbf4d629cf3d2bd3e89a70a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 28 Mar 2019 04:29:36 +0100 Subject: Rewrite readFile and writeFile (#2000) Using open/read/write --- js/buffer_test.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'js/buffer_test.ts') 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]); + } +}); -- cgit v1.2.3