From 48f88696858bd353f3471c7c8b161b2e23f7660b 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 4d22d670f6..78f3a48b60 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -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');