tests/codecs (a-m): comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:50:19 -05:00
1 parent a80299dce0
commit 5f7f6005f6
24 files changed
+46 -181

No files matched your search

+2 -10
View File
@@ -1,7 +1,5 @@
-- codecs/compress/Lzma tests: every fixture (liblzma through Python's lzma module and the xz CLI: presets 0-9 and -e, lc / lp /
-- pb variants, raw LZMA1 / LZMA2, .lzma files, xz with every check type, BCJ and delta filters, multiple blocks,
-- multiple streams and stream padding) decodes to its corpus; consumed offsets; checksum / size / truncation errors;
-- maxBytes; the fuzz no-throw pass. Fixtures: tools/fixtures/lzma.py.
-- codecs/compress/Lzma tests: liblzma (Python lzma, the xz CLI) .lzma / .xz / raw streams, check and size errors.
-- Fixtures: tools/fixtures/lzma.py.
local T = require("@tests/T")
local Lzma = require("@rosetta/codecs/compress/Lzma")
local Err = require("@rosetta/core/Err")
@@ -34,7 +32,6 @@ for _, c in Fx.cases do
end
t:note("%d fixture streams, %.1f MB decoded", #Fx.cases, nbytes / 1e6)
-- at an offset inside a bigger buffer, with trailing bytes
do
for _, c in Fx.cases do
if c.kind == "xz" and c.name == "text/xz-6" then
@@ -47,7 +44,6 @@ do
end
end
-- errors
do
local xz, xzc
for _, c in Fx.cases do
@@ -60,11 +56,9 @@ do
-- the check field: the last bytes before the index; flip a data bit near the end of the block instead
local b = buffer.fromstring(xzc.data)
local n = buffer.len(b)
-- footer magic
buffer.writeu8(b, n - 1, 0)
local _, e1 = Lzma.xz(b)
t:check(e1 and (e1.code == Err.CORRUPT or e1.code == Err.CHECKSUM), "bad footer: " .. tostring(e1))
-- the stream header CRC
local b2 = buffer.fromstring(xz.data)
buffer.writeu8(b2, 8, bit32.bxor(buffer.readu8(b2, 8), 1))
local _, e2 = Lzma.xz(b2)
@@ -83,7 +77,6 @@ do
-- truncations are TRUNCATED or CORRUPT, never a throw
local _, e4 = Lzma.xz(buffer.fromstring(string.sub(xzc.data, 1, #xzc.data // 2)))
t:check(e4 and e4.code == Err.TRUNCATED, "truncated xz: " .. tostring(e4))
-- maxBytes
local _, e5 = Lzma.xz(xzc.data, nil, nil, { maxBytes = 1000 })
t:check(e5 and e5.code == Err.LIMIT, "maxBytes: " .. tostring(e5))
local ok, r1, r2 = pcall(Lzma.xz, 5 :: any)
@@ -107,7 +100,6 @@ do
end
end
-- fuzz
do
local samples = {}
for i, c in Fx.cases do