aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-buffer-fill.js
diff options
context:
space:
mode:
authorJ Scott Chapman <scott8675309@gmail.com>2016-12-01 10:17:46 -0600
committerJames M Snell <jasnell@gmail.com>2016-12-05 15:16:09 -0800
commitcc1fa7a74d9ac5baa774fb33c135e30889c34d6e (patch)
tree514ea38915405a1bcde7638117bc9bcdf3d30751 /test/parallel/test-buffer-fill.js
parent6b43c3f33e2a8bdc37e8f505ba1cb7942b084fc8 (diff)
downloadandroid-node-v8-cc1fa7a74d9ac5baa774fb33c135e30889c34d6e.tar.gz
android-node-v8-cc1fa7a74d9ac5baa774fb33c135e30889c34d6e.tar.bz2
android-node-v8-cc1fa7a74d9ac5baa774fb33c135e30889c34d6e.zip
test: strictEqual() and RegExp in test-buffer-fill.js
Used assert.strictEqual() instead of assert.equal() Passed a RegExp to assert.throws() Broke lines to satisfy linting PR-URL: https://github.com/nodejs/node/pull/9895 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-buffer-fill.js')
-rw-r--r--test/parallel/test-buffer-fill.js48
1 files changed, 32 insertions, 16 deletions
diff --git a/test/parallel/test-buffer-fill.js b/test/parallel/test-buffer-fill.js
index c61ad59d7e..4272d68694 100644
--- a/test/parallel/test-buffer-fill.js
+++ b/test/parallel/test-buffer-fill.js
@@ -49,7 +49,7 @@ testBufs('\u0222aa', 8, 1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 4, -1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 4, 1, 'utf8');
testBufs('a\u0234b\u0235c\u0236', 12, 1, 'utf8');
-assert.equal(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8);
+assert.strictEqual(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8);
// BINARY
@@ -112,8 +112,8 @@ testBufs('\u0222aa', 8, 1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 4, -1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 4, 1, 'ucs2');
testBufs('a\u0234b\u0235c\u0236', 12, 1, 'ucs2');
-assert.equal(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0],
- os.endianness() === 'LE' ? 0x22 : 0x02);
+assert.strictEqual(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0],
+ os.endianness() === 'LE' ? 0x22 : 0x02);
// HEX
@@ -137,7 +137,8 @@ testBufs('61c8b462c8b563c8b6', 4, 1, 'hex');
testBufs('61c8b462c8b563c8b6', 12, 1, 'hex');
// Make sure this operation doesn't go on forever
buf1.fill('yKJh', 'hex');
-assert.throws(() => buf1.fill('\u0222', 'hex'));
+assert.throws(() =>
+ buf1.fill('\u0222', 'hex'), /^TypeError: Invalid hex string$/);
// BASE64
@@ -183,14 +184,25 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
// Check exceptions
-assert.throws(() => buf1.fill(0, -1));
-assert.throws(() => buf1.fill(0, 0, buf1.length + 1));
-assert.throws(() => buf1.fill('', -1));
-assert.throws(() => buf1.fill('', 0, buf1.length + 1));
-assert.throws(() => buf1.fill('a', 0, buf1.length, 'node rocks!'));
-assert.throws(() => buf1.fill('a', 0, 0, NaN));
-assert.throws(() => buf1.fill('a', 0, 0, null));
-assert.throws(() => buf1.fill('a', 0, 0, 'foo'));
+assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill(0, 0, buf1.length + 1),
+ /^RangeError: Out of range index$/);
+assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill('', 0, buf1.length + 1),
+ /^RangeError: Out of range index$/);
+assert.throws(() =>
+ buf1.fill('a', 0, buf1.length, 'node rocks!'),
+ /^TypeError: Unknown encoding: node rocks!$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, NaN),
+ /^TypeError: encoding must be a string$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, null),
+ /^TypeError: encoding must be a string$/);
+assert.throws(() =>
+ buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
function genBuffer(size, args) {
@@ -269,8 +281,12 @@ function testBufs(string, offset, length, encoding) {
}
// Make sure these throw.
-assert.throws(() => Buffer.allocUnsafe(8).fill('a', -1));
-assert.throws(() => Buffer.allocUnsafe(8).fill('a', 0, 9));
+assert.throws(() =>
+ Buffer.allocUnsafe(8).fill('a', -1),
+ /^RangeError: Out of range index$/);
+assert.throws(() =>
+ Buffer.allocUnsafe(8).fill('a', 0, 9),
+ /^RangeError: Out of range index$/);
// Make sure this doesn't hang indefinitely.
Buffer.allocUnsafe(8).fill('');
@@ -369,7 +385,7 @@ assert.throws(() => {
}
};
Buffer.alloc(1).fill(Buffer.alloc(1), 0, end);
- });
+ }, /^RangeError: out of range index$/);
// Make sure -1 is making it to Buffer::Fill().
assert.ok(elseWasLast,
'internal API changed, -1 no longer in correct location');
@@ -389,4 +405,4 @@ assert.throws(() => {
enumerable: true
});
buf.fill('');
-});
+}, /^RangeError: out of range index$/);