Skip to content

Commit

Permalink
test: improve buffer transcode
Browse files Browse the repository at this point in the history
This test is for argument validation in transcode.

PR-URL: #10043
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Johnny Reading authored and italoacasas committed Dec 12, 2016
1 parent f5c2c8c commit 9f58e02
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/parallel/test-icu-transcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ for (const test in tests) {
utf8_to_ucs2.toString('ucs2'));
}

assert.throws(
() => buffer.transcode(null, 'utf8', 'ascii'),
/^TypeError: "source" argument must be a Buffer$/
);

assert.throws(
() => buffer.transcode(Buffer.from('a'), 'b', 'utf8'),
/Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/
/^Error: Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/
);

assert.throws(
() => buffer.transcode(Buffer.from('a'), 'uf8', 'b'),
/Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/
/^Error: Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]$/
);

assert.deepStrictEqual(
Expand Down

0 comments on commit 9f58e02

Please sign in to comment.