tests/archive: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:49:50 -05:00
1 parent 54f53a35f6
commit 96602286f8
33 files changed
+34 -226

No files matched your search

+1 -14
View File
@@ -1,11 +1,4 @@
-- archive/cab tests: cabinets by gcab (stored / MSZIP), lcab, a builder of MSZIP blocks that use the previous block as
-- their dictionary (several folders, reserve areas, attributes, UTF-8 names) and libmspack's test cabinets give the
-- files cabextract extracts (names, sizes, data CRCs, DOS times read as UTC); cabextract / gcab / 7z extract our
-- writer's output (fixture step) and it round-trips; spanned files are UNSUPPORTED; checksum, truncation and
-- signature errors, libmspack's broken cabinets; LZX (codecs/compress/Lzx) from a fixture compressor whose cabinets
-- cabextract extracts (windows 2^15 .. 2^21, verbatim / aligned / uncompressed blocks, E8); Quantum
-- (codecs/compress/Quantum) the same way (windows 2^10 .. 2^21, model rescaling); Deflate's preset
-- dictionary; the fuzz pass. Fixtures: tools/fixtures/cab.py.
-- archive/cab tests against cabextract, gcab, lcab, 7z and libmspack's test cabinets (tools/fixtures/cab.py).
local T = require("@tests/T")
local F = require("@rosetta")
local Cab = require("@rosetta/archive/cab")
@@ -38,7 +31,6 @@ for _, c in Fx.cases do
end
t:check(methods.store and methods.mszip and methods.lzx and methods.quantum, "covers store, mszip, lzx and quantum")
-- attributes, UTF-8 names, reserve areas (the builder's two-folder cabinet)
local two = assert(load(Fx.cases[5].data))
local naive = two._byName["na\u{ef}ve \u{2603}.txt"]
t:check(naive and naive.utf8 and naive.attributes == 0x20, "utf-8 name and attributes")
@@ -47,7 +39,6 @@ t:eq(buffer.tostring(two.meta.reserve), "HEADER-RESERVE", "header reserve")
t:eq(#two.meta.folders, 2, "two folders")
t:check(assert(load(Fx.cases[4].data))._byName["b.bin"].readonly, "read-only attribute")
-- our writer
t:check(Fx.ours.ok, "reference tools extract our cabinets: " .. Fx.ours.log)
E.roundTrip(t, Cab, nil, "round trip mszip")
E.roundTrip(t, Cab, { compression = "none" }, "round trip store")
@@ -93,19 +84,16 @@ for _, c in Fx.bad do
table.insert(samples, c.data)
end
-- LZX directly
local Lzx = require("@rosetta/codecs/compress/Lzx")
t:check(not Lzx.decode(buffer.create(10), 0, 10, 100, 14), "LZX window 2^14 unsupported")
t:check(not Lzx.decode(buffer.create(10), 0, 10, 100, 16), "LZX of zeros")
t:check(not Lzx.decode(buffer.create(10), 4, 10, 100, 16), "LZX range past the end")
-- Quantum directly
local Quantum = require("@rosetta/codecs/compress/Quantum")
t:check(not Quantum.decode(buffer.create(10), {}, 0, 9), "Quantum window 2^9 unsupported")
t:check(not Quantum.decode(buffer.create(10), { { at = 0, len = 10, size = 5 } }, 6, 16), "Quantum sizes must add up")
t:check(not Quantum.decode(buffer.create(10), { { at = 4, len = 10, size = 5 } }, 5, 16), "Quantum range past the end")
-- Deflate's preset dictionary and MSZIP blocks
local block1 = assert(Deflate.compress(string.rep("ab", 50)))
local mszip = buffer.create(buffer.len(block1) + 2)
buffer.writestring(mszip, 0, "CK")
@@ -117,7 +105,6 @@ local z = assert(Deflate.compress(dictText .. dictText))
local plain = assert(Deflate.inflate(z, nil, nil, 1600, buffer.fromstring("unused prefix")))
t:eq(buffer.tostring(plain), dictText .. dictText, "inflate with an unused dictionary")
-- errors
local data = Fx.cases[2].data -- gcab -z
local function code(s: string): string?
local a, e = load(s)