Skip to content

Commit

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

feedback from approvers; full regex error msg & new line
  • Loading branch information
Johnny Reading committed Dec 6, 2016
1 parent 5887c2b commit e4ce550
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,11 +38,17 @@ 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\]$/
);

0 comments on commit e4ce550

Please sign in to comment.