Browse Source

test: improve buffer transcode

This test is for argument validation in transcode.

PR-URL: https://github.com/nodejs/node/pull/10043
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6
Johnny Reading 8 years ago
committed by Italo A. Casas
parent
commit
9f58e02908
  1. 10
      test/parallel/test-icu-transcode.js

10
test/parallel/test-icu-transcode.js

@ -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(

Loading…
Cancel
Save