From 2ec10cc9151920aa286a7ae376888d61cf9a3bca Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 14:55:08 +1100 Subject: src/defs.js: Refactor to_jsstring Now fails on non-utf8 input. Previously it would convert to equivalent unicode codepoints as bytes, which did not round-trip --- tests/defs.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/defs.js b/tests/defs.js index 07e863b..b00fda0 100644 --- a/tests/defs.js +++ b/tests/defs.js @@ -56,3 +56,11 @@ test('to_jsstring', function (t) { t.deepEqual(defs.to_jsstring(v.byte_array), v.literal, v.description); }); }); + +test('to_jsstring fails on invalid unicode', function (t) { + t.plan(1); + + t.throws(function() { + defs.to_jsstring([165]); + }, "non-utf8 char"); +}); -- cgit v1.2.3-70-g09d2