-- archive/applesingle tests (cases in tests/archive/_mac.luau). -- Fixtures: tools/fixtures/mac.py. local Mod = require("@rosetta/archive/applesingle") local Bytes = require("@rosetta/core/Bytes") local Err = require("@rosetta/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()