summaryrefslogtreecommitdiff
path: root/test/parallel/test-buffer-copy.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2019-08-09 07:29:48 -0400
committerRich Trott <rtrott@gmail.com>2019-08-14 15:59:32 -0700
commit6d351d4cc0a6feb644e7f81051d319b53bbc9309 (patch)
tree8c8f57272b4d69517d759472d5b19441d6ccf490 /test/parallel/test-buffer-copy.js
parente505a741e30d7101a0c4b9159d9e48589a76e16c (diff)
downloadandroid-node-v8-6d351d4cc0a6feb644e7f81051d319b53bbc9309.tar.gz
android-node-v8-6d351d4cc0a6feb644e7f81051d319b53bbc9309.tar.bz2
android-node-v8-6d351d4cc0a6feb644e7f81051d319b53bbc9309.zip
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/parallel/test-buffer-copy.js')
-rw-r--r--test/parallel/test-buffer-copy.js23
1 files changed, 15 insertions, 8 deletions
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);