test: improve code coverage for string decoder

PR-URL: https://github.com/nodejs/node/pull/22306
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Benjamin Chen 2018-08-14 02:10:17 -04:00 committed by Anna Henningsen
parent 902fd40ed5
commit 5673017c33
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -161,6 +161,16 @@ common.expectsError(
}
);
common.expectsError(
() => new StringDecoder('utf8').write(null),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "buf" argument must be one of type Buffer, Uint8Array, or' +
' ArrayBufferView. Received type object'
}
);
// test verifies that StringDecoder will correctly decode the given input
// buffer with the given encoding to the expected output. It will attempt all
// possible ways to write() the input buffer, see writeSequences(). The