From 9f58e029087b73609fb19a0f226996a4cc019789 Mon Sep 17 00:00:00 2001 From: Johnny Reading Date: Thu, 1 Dec 2016 11:53:56 -0600 Subject: [PATCH] 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 --- test/parallel/test-icu-transcode.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-icu-transcode.js b/test/parallel/test-icu-transcode.js index 2cdd4078a2c..c099e754ca5 100644 --- a/test/parallel/test-icu-transcode.js +++ b/test/parallel/test-icu-transcode.js @@ -39,12 +39,18 @@ for (const test in tests) { } assert.throws( - () => buffer.transcode(Buffer.from('a'), 'b', 'utf8'), - /Unable to transcode Buffer \[U_ILLEGAL_ARGUMENT_ERROR\]/ + () => buffer.transcode(null, 'utf8', 'ascii'), + /^TypeError: "source" argument must be a Buffer$/ ); + +assert.throws( + () => buffer.transcode(Buffer.from('a'), 'b', 'utf8'), + /^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(