summaryrefslogtreecommitdiff
path: root/test/parallel/test-buffer-read.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-01-30 17:34:25 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-03-02 19:29:46 +0000
commite8bb1f35df079cf0111fc18a8a24ec0a2d66eb3e (patch)
tree635c3c8e56a123fb45ab1f3136739aade631ba9c /test/parallel/test-buffer-read.js
parenta6c490cc8e8c848d6c4d5b8739827198055fe40f (diff)
downloadandroid-node-v8-e8bb1f35df079cf0111fc18a8a24ec0a2d66eb3e.tar.gz
android-node-v8-e8bb1f35df079cf0111fc18a8a24ec0a2d66eb3e.tar.bz2
android-node-v8-e8bb1f35df079cf0111fc18a8a24ec0a2d66eb3e.zip
buffer: refactor all read/write functions
There are a lot of changes in this commit: 1) Remove the `noAssert` argument from all read and write functions. 2) Improve the performance of all read floating point functions significantly. This is done by switching to TypedArrays as the write floating point write functions. 3) No implicit type coercion for offset and byteLength anymore. 4) Adds a lot of tests. 5) Moves the read and write functions to the internal buffer file to split the files in smaller chunks. 6) Reworked a lot of existing tests. 7) Improve the performane of all all read write functions by using a faster input validation and by improving function logic. 8) Significantly improved the performance of all read int functions. This is done by using a implementation without a loop. 9) Improved error handling. 10) Rename test file to use the correct subsystem. PR-URL: https://github.com/nodejs/node/pull/18395 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-buffer-read.js')
-rw-r--r--test/parallel/test-buffer-read.js25
1 files changed, 2 insertions, 23 deletions
diff --git a/test/parallel/test-buffer-read.js b/test/parallel/test-buffer-read.js
index ccde2cc3a2..e6a4f872b8 100644
--- a/test/parallel/test-buffer-read.js
+++ b/test/parallel/test-buffer-read.js
@@ -6,16 +6,11 @@ const assert = require('assert');
const buf = Buffer.from([0xa4, 0xfd, 0x48, 0xea, 0xcf, 0xff, 0xd9, 0x01, 0xde]);
function read(buff, funx, args, expected) {
-
assert.strictEqual(buff[funx](...args), expected);
common.expectsError(
() => buff[funx](-1, args[1]),
- {
- code: 'ERR_INDEX_OUT_OF_RANGE'
- }
+ { code: 'ERR_OUT_OF_RANGE' }
);
-
- assert.strictEqual(buff[funx](...args, true), expected);
}
// testing basic functionality of readDoubleBE() and readDoubleLE()
@@ -123,7 +118,7 @@ assert.throws(() => Buffer.allocUnsafe(8).readFloatLE(-1), RangeError);
(0xFFFFFFFF >> (32 - bits)));
});
-// test for common read(U)IntLE/BE
+// Test for common read(U)IntLE/BE
{
const buf = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05, 0x06]);
@@ -144,19 +139,3 @@ assert.throws(() => Buffer.allocUnsafe(8).readFloatLE(-1), RangeError);
assert.strictEqual(buf.readIntLE(0, 6), 0x060504030201);
assert.strictEqual(buf.readIntBE(0, 6), 0x010203040506);
}
-
-// test for byteLength parameter not between 1 and 6 (inclusive)
-common.expectsError(() => { buf.readIntLE(1); }, { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntLE(1, 'string'); },
- { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntLE(1, 0); },
- { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntLE(1, 7); },
- { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntBE(1); }, { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntBE(1, 'string'); },
- { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntBE(1, 0); },
- { code: 'ERR_OUT_OF_RANGE' });
-common.expectsError(() => { buf.readIntBE(1, 7); },
- { code: 'ERR_OUT_OF_RANGE' });