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 <cjihrig@gmail.com>
  • Loading branch information
Johnny Reading authored and Fishrock123 committed Dec 13, 2016
1 parent 3e8df73 commit 1f11deb
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 1f11deb

Please sign in to comment.