-
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 buffer transcode test #10043
Conversation
618e40a
to
5724dd2
Compare
Just curious, is there a reason you created a new file instead of adding it to test/parallel/test-icu-transcode.js? |
No reason other than I did not see that file. 😄 I'll move this test there. |
@@ -39,6 +39,10 @@ for (const test in tests) { | |||
} | |||
|
|||
assert.throws( | |||
() => buffer.transcode(null, 'utf8', 'ascii'), | |||
/TypeError: "source" argument must be a Buffer/ |
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.
If you're testing the entire error message, you can add ^
and $
to the regular expression.
@@ -39,6 +39,10 @@ for (const test in tests) { | |||
} | |||
|
|||
assert.throws( | |||
() => buffer.transcode(null, 'utf8', 'ascii'), | |||
/TypeError: "source" argument must be a Buffer/ | |||
); |
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.
tiny nit: new line here.
() => buffer.transcode(null, 'utf8', 'ascii'), | ||
/TypeError: "source" argument must be a Buffer/ | ||
); | ||
assert.throws( | ||
() => buffer.transcode(Buffer.from('a'), 'b', 'utf8'), | ||
/Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/ |
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.
Would be better to test the full error message here:
/^Error: Unable to transcode Buffer [U_ILLEGAL_ARGUMENT_ERROR]$/
This test is for argument validation in transcode. feedback from approvers; full regex error msg & new line
Landed 9f58e02 Thanks for the contribution. |
This test is for argument validation in transcode. PR-URL: #10043 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This test is for argument validation in transcode. PR-URL: #10043 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
This test is for argument validation in transcode.