diff options
author | Brian White <mscdex@mscdex.net> | 2019-08-09 07:29:48 -0400 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-14 15:59:32 -0700 |
commit | 6d351d4cc0a6feb644e7f81051d319b53bbc9309 (patch) | |
tree | 8c8f57272b4d69517d759472d5b19441d6ccf490 /test | |
parent | e505a741e30d7101a0c4b9159d9e48589a76e16c (diff) | |
download | node-new-6d351d4cc0a6feb644e7f81051d319b53bbc9309.tar.gz |
buffer: improve copy() performance
PR-URL: https://github.com/nodejs/node/pull/29066
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-buffer-alloc.js | 3 | ||||
-rw-r--r-- | test/parallel/test-buffer-copy.js | 23 |
2 files changed, 17 insertions, 9 deletions
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 75c2cae2b0..de3e7fa523 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -967,7 +967,8 @@ common.expectsError( { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'argument must be a buffer' + message: 'The "target" argument must be one of type Buffer or Uint8Array.' + + ' Received type undefined' }); assert.throws(() => Buffer.from(), { diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js index 9810c9824b..f668c26165 100644 --- a/test/parallel/test-buffer-copy.js +++ b/test/parallel/test-buffer-copy.js @@ -6,12 +6,6 @@ const assert = require('assert'); const b = Buffer.allocUnsafe(1024); const c = Buffer.allocUnsafe(512); -const errorProperty = { - code: 'ERR_OUT_OF_RANGE', - type: RangeError, - message: 'Index out of range' -}; - let cntr = 0; { @@ -116,7 +110,13 @@ b.copy(c, 0, 100, 10); // Copy throws at negative sourceStart common.expectsError( () => Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, -1), - errorProperty); + { + code: 'ERR_OUT_OF_RANGE', + type: RangeError, + message: 'The value of "sourceStart" is out of range. ' + + 'It must be >= 0. Received -1' + } +); { // Check sourceEnd resets to targetEnd if former is greater than the latter @@ -130,7 +130,14 @@ common.expectsError( // Throw with negative sourceEnd common.expectsError( - () => b.copy(c, 0, -1), errorProperty); + () => b.copy(c, 0, 0, -1), + { + code: 'ERR_OUT_OF_RANGE', + type: RangeError, + message: 'The value of "sourceEnd" is out of range. ' + + 'It must be >= 0. Received -1' + } +); // When sourceStart is greater than sourceEnd, zero copied assert.strictEqual(b.copy(c, 0, 100, 10), 0); |