-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add http-common's test #10832
test: add http-common's test #10832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good start. we should likely expand the range of tested inputs, however
const checkIsHttpToken = httpCommon._checkIsHttpToken; | ||
const checkInvalidHeaderChar = httpCommon._checkInvalidHeaderChar; | ||
|
||
// checkishttptoken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the comments match the case of the function calls.
assert(checkIsHttpToken('tttt')); | ||
assert(checkIsHttpToken('ttttt')); | ||
|
||
assert(!checkIsHttpToken(' ')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you switch to assert.strictEqual()
. It will make the code more readable, especially in the negated cases.
c747717
to
edcf201
Compare
@cjihrig Updated. |
assert.strictEqual(checkIsHttpToken('aaaaあaaaa'), false); | ||
|
||
// checkInvalidHeaderChar | ||
assert.strictEqual(checkInvalidHeaderChar(1), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: how about adding the empty string case? It should slightly increase the coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Added the empty string case.
edcf201
to
9c3b340
Compare
9c3b340
to
67d6261
Compare
Landed 165bf28 |
PR-URL: #10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10832 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Add a test of
checkIsHttpToken
andcheckInvalidHeaderChar
.checkIsHttpToken: https://github.com/nodejs/node/blob/master/lib/_http_common.js#L267
checkInvalidHeaderChar: https://github.com/nodejs/node/blob/master/lib/_http_common.js#L318
Coverage: https://coverage.nodejs.org/coverage-57f6a106fbc69a47/root/_http_common.js.html
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test