tests/image: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:50:18 -05:00
1 parent e306d5c1d7
commit a80299dce0
27 files changed
+32 -199

No files matched your search

+1 -12
View File
@@ -1,7 +1,4 @@
-- image/tiff tests: files written by tifffile / imagecodecs and ImageMagick (every compression, predictors, strips and
-- tiles, planar, both byte orders, BigTIFF, 1..32-bit integer and 16 / 32 / 64-bit float samples, palette, CMYK,
-- alpha, multi-page) against tifffile's decode, in rgba8 and native layouts; the JPEG hook; encoder round trips for
-- every layout and compression; errors; the fuzz pass. Fixtures: tools/fixtures/tiff.py.
-- image/tiff tests against tifffile's decode (tools/fixtures/tiff.py).
local T = require("@tests/T")
local Tiff = require("@rosetta/image/tiff")
local Bytes = require("@rosetta/core/Bytes")
@@ -17,14 +14,12 @@ local function decode(data: any, opts: any?): (any, any)
return Tiff.decode(Bytes.reader(b), opts)
end
-- contract
t:eq(Tiff.name, "tiff", "name")
t:check(Tiff.caps.decode and Tiff.caps.encode, "caps")
t:eq(Tiff.sniff(Bytes.reader(buffer.fromstring("II*\0\8\0\0\0"))), 1, "sniff II")
t:eq(Tiff.sniff(Bytes.reader(buffer.fromstring("MM\0*"))), 1, "sniff MM")
t:eq(Tiff.sniff(Bytes.reader(buffer.fromstring("\137PNG"))), 0, "sniff png")
-- reference files
local pagesChecked = 0
for _, c in Fx.cases do
local img, err = decode(c.data)
@@ -43,7 +38,6 @@ for _, c in Fx.cases do
t:check(ncrc == p.ncrc, string.format("%s page %d: native crc %08x, want %08x", c.name, i, ncrc, p.ncrc))
pagesChecked += 1
end
-- inside a bigger buffer
local big = buffer.create(#c.data + 9)
buffer.writestring(big, 5, c.data)
local img3 = Tiff.decode(Bytes.reader(big, 5, #c.data))
@@ -51,7 +45,6 @@ for _, c in Fx.cases do
end
t:note("%d files, %d pages match tifffile", #Fx.cases, pagesChecked)
-- info, single page, meta
do
local multi
for _, c in Fx.cases do
@@ -104,7 +97,6 @@ do
t:note("JPEG-in-TIFF through F.load: max error %d against tifffile / libjpeg-turbo", worst)
end
-- encoder round trips
do
local rand = T.rng(11)
local function image(fmt: string, w: number, h: number): Types.Image
@@ -141,7 +133,6 @@ do
end
end
t:note("%d encoder round trips", trips)
-- multi-page
local a, b = image("rgb8", 20, 10), image("gray16", 7, 9)
local anim = image("rgb8", 20, 10)
anim.frames = { { image = a, delay = 0, x = 0, y = 0, dispose = "none", blend = "source" }, { image = b, delay = 0, x = 0, y = 0, dispose = "none", blend = "source" } } :: any
@@ -158,7 +149,6 @@ do
t:check(e3 and e3.code == Err.ARG, "unsupported layout")
end
-- errors
do
local _, e = decode("II*\0\255\255\0\0")
t:check(e and (e.code == Err.TRUNCATED or e.code == Err.CORRUPT), "bad IFD offset")
@@ -166,7 +156,6 @@ do
t:check(e2 and e2.code == Err.TRUNCATED or e2.code == Err.CORRUPT, "junk")
end
-- fuzz
do
local samples = {}
for i, c in Fx.cases do