From a20071c00d1bdc32b9d8e7115b109a948f024109 Mon Sep 17 00:00:00 2001 From: xiaoyu <306766053@qq.com> Date: Fri, 17 Feb 2017 00:24:39 +0800 Subject: [PATCH 1/3] test: add coverage for utf8CheckIncomplete() --- 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 4d22d670f63d6d..67aefaf0e9c0f7 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, 0x42]), 1), 'B'); // Additional UTF-16LE surrogate pair tests decoder = new StringDecoder('utf16le'); From cd5aa63dc560f1e750882b7653dd6d7253e31bc6 Mon Sep 17 00:00:00 2001 From: xiaoyu <306766053@qq.com> Date: Fri, 17 Feb 2017 00:37:29 +0800 Subject: [PATCH 2/3] test: add coverage for utf8CheckIncomplete() --- test/parallel/test-string-decoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index 67aefaf0e9c0f7..97098e5f588648 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -85,7 +85,7 @@ assert.strictEqual(decoder.end(), '\ufffd'); //Additional utf8Text test decoder = new StringDecoder('utf8'); -assert.strictEqual(decoder.text(Buffer.from([0x41, 0x42]), 1), 'B'); +assert.strictEqual(decoder.text(Buffer.from([0x41]), 2), ''); // Additional UTF-16LE surrogate pair tests decoder = new StringDecoder('utf16le'); From ab6e199651483b039c31a006b7f57e79ea36404e Mon Sep 17 00:00:00 2001 From: xiaoyu <306766053@qq.com> Date: Fri, 17 Feb 2017 08:39:26 +0800 Subject: [PATCH 3/3] lint fix --- test/parallel/test-string-decoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index 97098e5f588648..78f3a48b608da6 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -83,7 +83,7 @@ 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 +// Additional utf8Text test decoder = new StringDecoder('utf8'); assert.strictEqual(decoder.text(Buffer.from([0x41]), 2), '');