Skip to content

Commit cc8100a

Browse files
levsorokaaddaleax
authored andcommitted
test: fix buffer alloc tests
Replaced assert.equal to assert.strictEqual. Fixed assert.throws syntax and added second argument PR-URL: #9998 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent eb61d91 commit cc8100a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/parallel/test-buffer-alloc.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
138138
const sliceA = b.slice(offset, offset + asciiString.length);
139139
const sliceB = b.slice(offset, offset + asciiString.length);
140140
for (let i = 0; i < asciiString.length; i++) {
141-
assert.equal(sliceA[i], sliceB[i]);
141+
assert.strictEqual(sliceA[i], sliceB[i]);
142142
}
143143
}
144144

@@ -149,7 +149,7 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
149149

150150
b.write(utf8String, 0, Buffer.byteLength(utf8String), 'utf8');
151151
let utf8Slice = b.toString('utf8', 0, Buffer.byteLength(utf8String));
152-
assert.equal(utf8String, utf8Slice);
152+
assert.strictEqual(utf8String, utf8Slice);
153153

154154
assert.strictEqual(Buffer.byteLength(utf8String),
155155
b.write(utf8String, offset, 'utf8'));
@@ -1057,7 +1057,8 @@ assert.strictEqual(Buffer.allocUnsafe(1).parent, undefined);
10571057
Buffer.poolSize = ps;
10581058

10591059
// Test Buffer.copy() segfault
1060-
assert.throws(() => Buffer.allocUnsafe(10).copy());
1060+
assert.throws(() => Buffer.allocUnsafe(10).copy(),
1061+
/TypeError: argument should be a Buffer/);
10611062

10621063
const regErrorMsg = new RegExp('First argument must be a string, Buffer, ' +
10631064
'ArrayBuffer, Array, or array-like object.');
@@ -1066,10 +1067,10 @@ assert.throws(() => Buffer.from(), regErrorMsg);
10661067
assert.throws(() => Buffer.from(null), regErrorMsg);
10671068

10681069
// Test prototype getters don't throw
1069-
assert.equal(Buffer.prototype.parent, undefined);
1070-
assert.equal(Buffer.prototype.offset, undefined);
1071-
assert.equal(SlowBuffer.prototype.parent, undefined);
1072-
assert.equal(SlowBuffer.prototype.offset, undefined);
1070+
assert.strictEqual(Buffer.prototype.parent, undefined);
1071+
assert.strictEqual(Buffer.prototype.offset, undefined);
1072+
assert.strictEqual(SlowBuffer.prototype.parent, undefined);
1073+
assert.strictEqual(SlowBuffer.prototype.offset, undefined);
10731074

10741075

10751076
{
@@ -1095,7 +1096,7 @@ assert.throws(() => {
10951096
const a = Buffer.alloc(1);
10961097
const b = Buffer.alloc(1);
10971098
a.copy(b, 0, 0x100000000, 0x100000001);
1098-
}), /out of range index/;
1099+
}, /out of range index/);
10991100

11001101
// Unpooled buffer (replaces SlowBuffer)
11011102
{

0 commit comments

Comments
 (0)