From e4ce550c63ec70b733ac265af1b8f654ed30a656 Mon Sep 17 00:00:00 2001 From: Johnny Reading Date: Thu, 1 Dec 2016 11:53:56 -0600 Subject: [PATCH] test: add buffer transcode test This test is for argument validation in transcode. feedback from approvers; full regex error msg & new line --- test/parallel/test-icu-transcode.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-icu-transcode.js b/test/parallel/test-icu-transcode.js index f45b9974367af3..4ead5d3f23e30b 100644 --- a/test/parallel/test-icu-transcode.js +++ b/test/parallel/test-icu-transcode.js @@ -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\]$/ );