Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3666662

Browse filesBrowse files
Saud Khanzadatargos
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 <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent a7e8949 commit 3666662
Copy full SHA for 3666662

File tree

Expand file treeCollapse file tree

1 file changed

+28
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-4
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-buffer-alloc.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-alloc.js
+28-4Lines changed: 28 additions & 4 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.