summaryrefslogtreecommitdiff
path: root/test/parallel/test-string-decoder.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-string-decoder.js')
-rw-r--r--test/parallel/test-string-decoder.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js
index 5571aaeeb7..6e4f4b121d 100644
--- a/test/parallel/test-string-decoder.js
+++ b/test/parallel/test-string-decoder.js
@@ -143,6 +143,14 @@ decoder = new StringDecoder('utf16le');
assert.strictEqual(decoder.write(Buffer.from('3DD84D', 'hex')), '\ud83d');
assert.strictEqual(decoder.end(), '');
+// Regression test for https://github.com/nodejs/node/issues/22358
+// (unaligned UTF-16 access).
+decoder = new StringDecoder('utf16le');
+assert.strictEqual(decoder.write(Buffer.alloc(1)), '');
+assert.strictEqual(decoder.write(Buffer.alloc(20)), '\0'.repeat(10));
+assert.strictEqual(decoder.write(Buffer.alloc(48)), '\0'.repeat(24));
+assert.strictEqual(decoder.end(), '');
+
common.expectsError(
() => new StringDecoder(1),
{