发布 0.2.1 并完善工具边界与安全性

This commit is contained in:
mid
2026-08-10 14:49:43 +08:00
parent aca004c513
commit 32b7cc827c
47 changed files with 681 additions and 172 deletions
+8
View File
@@ -48,6 +48,14 @@ describe('CRC', () => {
expect(calculateCrcChunks(chunks, preset)).toBe(calculateCrc(textToBytes('123456789'), preset))
})
it('rejects malformed runtime parameters instead of coercing them', () => {
const preset = CRC_PRESETS[0]
expect(() => calculateCrc(new Uint8Array(), { ...preset, inputReflected: undefined as never })).toThrow('布尔值')
expect(() => calculateCrc(new Uint8Array(), { ...preset, polynomial: 7 as never })).toThrow('BigInt')
expect(() => formatCrc(0x100n, 8)).toThrow('超出当前位宽')
expect(() => formatCrc(0n, 7)).toThrow('位宽')
})
it('reports both the combined CRC and each block CRC', () => {
const parameters = CRC_PRESETS.find((preset) => preset.id === 'crc-32-iso-hdlc')!
const blocks = [