Skip to content

Commit 3666662

Browse files
Saud Khanzadatargos
Saud Khanzada
authored andcommitted
test: replaces assert.throws() with common.expectsError()
replaces assert.throws() with common.expectsError() to check error code and error type in parallel/test-buffer-alloc.js PR-URL: #22689 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent a7e8949 commit 3666662

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

test/parallel/test-buffer-alloc.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,40 @@ new Buffer('', 'binary');
7575
Buffer(0);
7676

7777
// try to write a 0-length string beyond the end of b
78-
assert.throws(() => b.write('', 2048), RangeError);
78+
common.expectsError(
79+
() => b.write('', 2048),
80+
{
81+
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
82+
type: RangeError
83+
}
84+
);
7985

8086
// throw when writing to negative offset
81-
assert.throws(() => b.write('a', -1), RangeError);
87+
common.expectsError(
88+
() => b.write('a', -1),
89+
{
90+
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
91+
type: RangeError
92+
}
93+
);
8294

8395
// throw when writing past bounds from the pool
84-
assert.throws(() => b.write('a', 2048), RangeError);
96+
common.expectsError(
97+
() => b.write('a', 2048),
98+
{
99+
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
100+
type: RangeError
101+
}
102+
);
85103

86104
// throw when writing to negative offset
87-
assert.throws(() => b.write('a', -1), RangeError);
105+
common.expectsError(
106+
() => b.write('a', -1),
107+
{
108+
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
109+
type: RangeError
110+
}
111+
);
88112

89113
// try to copy 0 bytes worth of data into an empty buffer
90114
b.copy(Buffer.alloc(0), 0, 0, 0);

0 commit comments

Comments
 (0)