aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-29 21:23:10 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-29 21:23:10 -0800
commit98becc3538a4f08b7abbe797e2dc14be9290705e (patch)
tree73ad8f867ff02ee9b60faed8a56c68a1e43ceb4d /test
parent49d8316922cb2ca65a7d4d8e2a2339eda110e3ad (diff)
downloadbun-98becc3538a4f08b7abbe797e2dc14be9290705e.tar.gz
bun-98becc3538a4f08b7abbe797e2dc14be9290705e.tar.zst
bun-98becc3538a4f08b7abbe797e2dc14be9290705e.zip
Add another latin1 test
Diffstat (limited to 'test')
-rw-r--r--test/bun.js/text-encoder.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/bun.js/text-encoder.test.js b/test/bun.js/text-encoder.test.js
index 94926b57a..7d3a11032 100644
--- a/test/bun.js/text-encoder.test.js
+++ b/test/bun.js/text-encoder.test.js
@@ -37,6 +37,22 @@ describe("TextEncoder", () => {
}
expect(encoded.length).toBe(result.length);
expect(out.written).toBe(result.length);
+
+ const repeatCOunt = 16;
+ text = "H©ell©o Wor©ld!".repeat(repeatCOunt);
+ const byteLength = getByteLength(text);
+ const encoded2 = encoder.encode(text);
+ expect(encoded2.length).toBe(byteLength);
+ const into2 = new Uint8Array(byteLength);
+ const out2 = encoder.encodeInto(text, into2);
+ expect(out2.read).toBe(text.length);
+ expect(out2.written).toBe(byteLength);
+ expect(into2).toEqual(encoded2);
+ const repeatedResult = new Uint8Array(byteLength);
+ for (let i = 0; i < repeatCOunt; i++) {
+ repeatedResult.set(result, i * result.length);
+ }
+ expect(into2).toEqual(repeatedResult);
});
it("should encode latin1 text", () => {