Skip to content

Commit 9d1be7c

Browse files
committed
test: add x-user-defined test
1 parent 2e0b72d commit 9d1be7c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/single-byte.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,15 @@ describe('single-byte encodings index', () => {
119119
})
120120
}
121121
})
122+
123+
// https://encoding.spec.whatwg.org/#x-user-defined-decoder
124+
test('x-user-defined', (t) => {
125+
const encoding = 'x-user-defined'
126+
const decoder = createSinglebyteDecoder(encoding)
127+
const decoderLoose = createSinglebyteDecoder(encoding, true)
128+
for (let byte = 0; byte < 256; byte++) {
129+
const str = String.fromCodePoint(byte >= 0x80 ? 0xf7_80 + byte - 0x80 : byte)
130+
t.assert.strictEqual(decoder(Uint8Array.of(byte)), str, byte)
131+
t.assert.strictEqual(decoderLoose(Uint8Array.of(byte)), str, byte)
132+
}
133+
})

0 commit comments

Comments
 (0)