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 cf5579d

Browse filesBrowse files
lfkwtzItalo A. Casas
authored andcommitted
test: improve zlib-from-gzip-with-trailing-garbage
* use assert.strictEqual instead of assert.equal * add RegExp in second argument of assert.throws * validate error message and code PR-URL: #10674 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 2d85609 commit cf5579d
Copy full SHA for cf5579d

File tree

Expand file treeCollapse file tree

1 file changed

+22
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-6
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-zlib-from-gzip-with-trailing-garbage.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib-from-gzip-with-trailing-garbage.js
+22-6Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ let data = Buffer.concat([
1212
Buffer(10).fill(0)
1313
]);
1414

15-
assert.equal(zlib.gunzipSync(data).toString(), 'abcdef');
15+
assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef');
1616

1717
zlib.gunzip(data, common.mustCall((err, result) => {
1818
assert.ifError(err);
19-
assert.equal(result, 'abcdef', 'result should match original string');
19+
assert.strictEqual(
20+
result.toString(),
21+
'abcdef',
22+
'result should match original string'
23+
);
2024
}));
2125

2226
// if the trailing garbage happens to look like a gzip header, it should
@@ -28,10 +32,16 @@ data = Buffer.concat([
2832
Buffer(10).fill(0)
2933
]);
3034

31-
assert.throws(() => zlib.gunzipSync(data));
35+
assert.throws(
36+
() => zlib.gunzipSync(data),
37+
/^Error: unknown compression method$/
38+
);
3239

3340
zlib.gunzip(data, common.mustCall((err, result) => {
34-
assert(err);
41+
assert(err instanceof Error);
42+
assert.strictEqual(err.code, 'Z_DATA_ERROR');
43+
assert.strictEqual(err.message, 'unknown compression method');
44+
assert.strictEqual(result, undefined);
3545
}));
3646

3747
// In this case the trailing junk is too short to be a gzip segment
@@ -42,8 +52,14 @@ data = Buffer.concat([
4252
Buffer([0x1f, 0x8b, 0xff, 0xff])
4353
]);
4454

45-
assert.throws(() => zlib.gunzipSync(data));
55+
assert.throws(
56+
() => zlib.gunzipSync(data),
57+
/^Error: unknown compression method$/
58+
);
4659

4760
zlib.gunzip(data, common.mustCall((err, result) => {
48-
assert(err);
61+
assert(err instanceof Error);
62+
assert.strictEqual(err.code, 'Z_DATA_ERROR');
63+
assert.strictEqual(err.message, 'unknown compression method');
64+
assert.strictEqual(result, undefined);
4965
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.