diff options
author | Nikolai Vavilov <vvnicholas@gmail.com> | 2020-05-06 20:10:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 13:10:15 -0400 |
commit | 76c77bb32c642283e61c9a6bb4936401fc43eaba (patch) | |
tree | 2103b4a94cc285b0164a744e486c0ea7b3e2adc5 /cli/js/tests/text_encoding_test.ts | |
parent | 91369841ef19b41dcdc7934d39620fedc3a0f6c8 (diff) |
Check destination length in encodeInto (#5078)
Diffstat (limited to 'cli/js/tests/text_encoding_test.ts')
-rw-r--r-- | cli/js/tests/text_encoding_test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/js/tests/text_encoding_test.ts b/cli/js/tests/text_encoding_test.ts index c8a7fbe42..87b601f36 100644 --- a/cli/js/tests/text_encoding_test.ts +++ b/cli/js/tests/text_encoding_test.ts @@ -158,6 +158,19 @@ unitTest(function textEncodeInto2(): void { ]); }); +unitTest(function textEncodeInto3(): void { + const fixture = "𝓽𝓮𝔁𝓽"; + const encoder = new TextEncoder(); + const bytes = new Uint8Array(5); + const result = encoder.encodeInto(fixture, bytes); + assertEquals(result.read, 2); + assertEquals(result.written, 4); + // prettier-ignore + assertEquals(Array.from(bytes), [ + 0xf0, 0x9d, 0x93, 0xbd, 0x00, + ]); +}); + unitTest(function textDecoderSharedUint8Array(): void { const ab = new SharedArrayBuffer(6); const dataView = new DataView(ab); |