import { test } from '@japa/runner' import { readFileSync } from 'node:fs' import { lzmaDecode, LzmaError } from '#lib/sevenzip/lzma' const fixture = (name: string) => readFileSync(new URL(`../../fixtures/sevenzip/${name}`, import.meta.url)) test.group('probe / LZMA', () => { test('decodes a stream Python made (.lzma: 5 property bytes, the size, the raw stream)', ({ assert }) => { const alone = fixture('sample.lzma') const expected = fixture('sample.bin') const decoded = lzmaDecode(alone.subarray(0, 5), alone.subarray(13), expected.length) assert.isTrue(decoded.equals(expected)) }) test('a cut-off or damaged stream throws LzmaError', ({ assert }) => { const alone = fixture('sample.lzma') const size = fixture('sample.bin').length assert.throws(() => lzmaDecode(alone.subarray(0, 5), alone.subarray(13, 200), size), LzmaError) }) })