test: add coverage for utf8CheckIncomplete()

This commit adds code coverage to utf8CheckIncomplete(), when the
lastNeed is greater than buffer length.

PR-URL: https://github.com/nodejs/node/pull/11419
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
xiaoyu 2017-02-17 00:24:39 +08:00 committed by Michaël Zasso
parent a1c652ae60
commit 48f8869685

View File

@ -83,6 +83,9 @@ assert.strictEqual(decoder.write(Buffer.from('F1', 'hex')), '');
assert.strictEqual(decoder.write(Buffer.from('41F2', 'hex')), '\ufffdA');
assert.strictEqual(decoder.end(), '\ufffd');
// Additional utf8Text test
decoder = new StringDecoder('utf8');
assert.strictEqual(decoder.text(Buffer.from([0x41]), 2), '');
// Additional UTF-16LE surrogate pair tests
decoder = new StringDecoder('utf16le');