Skip to content

Commit

Permalink
test: add exception tests to punycode
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jan 27, 2017
1 parent 25c1751 commit 463f756
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/parallel/test-punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ assert.strictEqual(
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'
);
assert.strictEqual(punycode.encode('日本語'), 'wgv71a119e');
assert.throws(() => {
punycode.encode();
}, /^TypeError: Argument must not be "undefined" and "null"$/);
assert.throws(() => {
punycode.encode(null);
}, /^TypeError: Argument must not be "undefined" and "null"$/);

assert.strictEqual(punycode.decode('tda'), 'ü');
assert.strictEqual(punycode.decode('Goethe-'), 'Goethe');
Expand All @@ -25,14 +31,20 @@ assert.strictEqual(
);
assert.strictEqual(punycode.decode('wgv71a119e'), '日本語');
assert.throws(() => {
punycode.decode(' ');
}, /^RangeError: Invalid input$/);
punycode.decode();
}, /^TypeError: Argument must be a string$/);
assert.throws(() => {
punycode.decode([]);
}, /^TypeError: Argument must be a string$/);
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$/);
assert.throws(() => {
punycode.decode(' ');
}, /^RangeError: Invalid input$/);

// http://tools.ietf.org/html/rfc3492#section-7.1
const tests = [
Expand Down

0 comments on commit 463f756

Please sign in to comment.