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
constsliceA=b.slice(offset,offset+asciiString.length);
139139
constsliceB=b.slice(offset,offset+asciiString.length);
140140
for(leti=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
letutf8Slice=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:argumentshouldbeaBuffer/);
10611062

10621063
constregErrorMsg=newRegExp('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
consta=Buffer.alloc(1);
10961097
constb=Buffer.alloc(1);
10971098
a.copy(b,0,0x100000000,0x100000001);
1098-
}),/outofrangeindex/;
1099+
},/outofrangeindex/);
10991100

11001101
// Unpooled buffer (replaces SlowBuffer)
11011102
{

0 commit comments

Comments
(0)