ws-arch2: archive/binhex, archive/macbinary (I / II / III), archive/applesingle (AppleSingle / AppleDouble v1 / v2), read + write, over the new containers/MacFile (fork convention, Mac OS Roman names, 1904 dates)

This commit is contained in:
4DBug committed 2026-10-31 14:11:03 -05:00
1 parent fe44292f58
commit 3243291877
13 files changed
+1152 -4

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
-- archive/applesingle tests: the applesingle cases of tools/fixtures/mac.py against The Unarchiver's listings, our output read by unar,
-- round trips with a resource fork and Finder info (tests/archive/_mac.luau), errors, the fuzz pass.
local Mod = require("@formats/archive/applesingle")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local run = require("@tests/archive/_mac")
local t, samples = run("applesingle", Mod, { {}, { double = true } })
local function code(s: string): string?
local _, e = Mod.decode(Bytes.reader(buffer.fromstring(s)))
return e and e.code
end
local good = buffer.tostring(Mod.encode("hello", { name = "h" }) :: buffer)
t:eq(code(string.sub(good, 1, 30)), Err.TRUNCATED, "entry table cut")
t:eq(code(string.sub(good, 1, #good - 2)), Err.TRUNCATED, "entry past the end")
t:eq(code("\0\5\22\0\0\3\0\0" .. string.rep("\0", 20)), Err.CORRUPT, "bad version")
-- the AppleDouble name comes from the file name without "._"
local d = Mod.decode(Bytes.reader(Mod.encode("x", { double = true, name = "" }) :: buffer), { name = "dir/._Report" }) :: any
t:check(d and d.meta.double, "appledouble flag")
t:fuzz("decode", function(b: buffer)
return Mod.decode(Bytes.reader(b))
end, samples)
t:done()