From 8da156d68f6e653c53dc03ca8ffd836b84690f07 Mon Sep 17 00:00:00 2001 From: xiaoyu <306766053@qq.com> Date: Fri, 17 Feb 2017 00:24:39 +0800 Subject: [PATCH] test: add coverage for utf8CheckIncomplete() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Michaƫl Zasso --- test/parallel/test-string-decoder.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index 151ae8b4e0b11a..9ecf0a8670b59c 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -87,6 +87,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');