Skip to content

Commit d8cd85c

Browse files
committed
test: isomorphicEncode returns non-pooled Uint8Array instances
1 parent b1cbe0f commit d8cd85c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tests/encoding/nopool.test.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { TextEncoder } from '@exodus/bytes/encoding.js'
1+
import { TextEncoder, isomorphicEncode } from '@exodus/bytes/encoding.js'
22
import { test } from 'node:test'
33

4-
test('TextEncoder returns non-pooled buffers', (t) => {
4+
test('TextEncoder returns non-pooled Uint8Array instances', (t) => {
55
const encoder = new TextEncoder()
66
for (let i = 0; i < 256; i++) {
77
t.assert.strictEqual(encoder.encode('x'.repeat(128)).buffer.byteLength, 128)
@@ -19,3 +19,21 @@ test('TextEncoder returns non-pooled buffers', (t) => {
1919
t.assert.strictEqual(encoder.encode('').buffer.byteLength, 0)
2020
}
2121
})
22+
23+
test('isomorphicEncode returns non-pooled Uint8Array instances', (t) => {
24+
for (let i = 0; i < 256; i++) {
25+
t.assert.strictEqual(isomorphicEncode('x'.repeat(128)).buffer.byteLength, 128)
26+
}
27+
28+
for (let i = 0; i < 256; i++) {
29+
t.assert.strictEqual(isomorphicEncode('x'.repeat(64)).buffer.byteLength, 64)
30+
}
31+
32+
for (let i = 0; i < 512; i++) {
33+
t.assert.strictEqual(isomorphicEncode('x'.repeat(32)).buffer.byteLength, 32)
34+
}
35+
36+
for (let i = 0; i < 512; i++) {
37+
t.assert.strictEqual(isomorphicEncode('').buffer.byteLength, 0)
38+
}
39+
})

0 commit comments

Comments
 (0)