发布 0.2.1 并完善工具边界与安全性
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user