From bddfef3bb06f2bcfbdac17ed59a17cfac32e0168 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Sat, 21 Jan 2017 21:47:45 +0900 Subject: [PATCH] test: increase coverage for punycode's decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added test cases for error. PR-URL: https://github.com/nodejs/node/pull/10940 Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/parallel/test-punycode.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-punycode.js b/test/parallel/test-punycode.js index 7d969c66ee4e13..2918202326bf98 100644 --- a/test/parallel/test-punycode.js +++ b/test/parallel/test-punycode.js @@ -18,6 +18,15 @@ assert.strictEqual(punycode.decode( 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'), 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'); assert.strictEqual(punycode.decode('wgv71a119e'), '日本語'); +assert.throws(() => { + punycode.decode(' '); +}, /^RangeError: Invalid input$/); +assert.throws(() => { + punycode.decode('α-'); +}, /^RangeError: Illegal input >= 0x80 \(not a basic code point\)$/); +assert.throws(() => { + punycode.decode('あ'); +}, /^RangeError: Overflow: input needs wider integers to process$/); // http://tools.ietf.org/html/rfc3492#section-7.1 const tests = [