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:
1 parent
fe44292f58
commit
3243291877
13 files changed
+1152
-4
No files matched your search
@@ -0,0 +1,24 @@
|
||||
-- archive/macbinary tests: the macbinary 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/macbinary")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Err = require("@formats/core/Err")
|
||||
local run = require("@tests/archive/_mac")
|
||||
|
||||
local t, samples = run("macbinary", Mod, { {} })
|
||||
local function code(s: string): string?
|
||||
local _, e = Mod.decode(Bytes.reader(buffer.fromstring(s)))
|
||||
return e and e.code
|
||||
end
|
||||
local good = Mod.encode("hello macbinary", { name = "h" }) :: buffer
|
||||
local bad = buffer.create(buffer.len(good))
|
||||
buffer.copy(bad, 0, good)
|
||||
buffer.writeu8(bad, 70, 1)
|
||||
t:eq(code(buffer.tostring(bad)), Err.CHECKSUM, "header CRC")
|
||||
t:eq(code(string.sub(buffer.tostring(good), 1, 140)), Err.TRUNCATED, "short data fork")
|
||||
t:eq(code(string.rep("\1", 200)), Err.CORRUPT, "not MacBinary")
|
||||
t:eq(code("short"), Err.TRUNCATED, "short header")
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
return Mod.decode(Bytes.reader(b))
|
||||
end, samples, { keepHeader = 0 })
|
||||
t:done()
|
||||
Reference in new issue
Block a user