From 3160b0286d030b182f9508b9a9cda79a74a98186 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 f895e2fc0e2607..60175557042ff9 100644 --- a/test/parallel/test-punycode.js +++ b/test/parallel/test-punycode.js @@ -24,6 +24,15 @@ assert.strictEqual( '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 = [