tests/image: comments: specs only
This commit is contained in:
1 parent
e306d5c1d7
commit
a80299dce0
27 files changed
+32
-199
No files matched your search
@@ -1,5 +1,4 @@
|
||||
-- tests/image/_raster: the shared checks of the simple raster formats' tests (pcx, sgi, sunras, xbm, xpm, ilbm, icns,
|
||||
-- ani): decode every case against its reference rgba8 pixels, round-trip images through the encoder, fuzz samples.
|
||||
-- shared checks of the simple raster formats' tests: decode against reference rgba8, round trips, fuzz samples.
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
local Types = require("@rosetta/Types")
|
||||
|
||||
@@ -17,7 +16,6 @@ local function maxDiff(a: buffer, b: buffer, n: number): (number, number)
|
||||
end
|
||||
R.maxDiff = maxDiff
|
||||
|
||||
-- cases: { { name, data, w, h, rgba, tol? } } (rgba: the reference decode)
|
||||
function R.decodes(t: any, Fmt: any, cases: { any }, opts: any?): number
|
||||
local n = 0
|
||||
for _, c in cases do
|
||||
@@ -31,7 +29,6 @@ function R.decodes(t: any, Fmt: any, cases: { any }, opts: any?): number
|
||||
end
|
||||
n += 1
|
||||
end
|
||||
-- from inside a bigger buffer
|
||||
local big = buffer.create(#c.data + 9)
|
||||
buffer.writestring(big, 5, c.data)
|
||||
local img2 = Fmt.decode(Bytes.reader(big, 5, #c.data), opts)
|
||||
@@ -40,14 +37,12 @@ function R.decodes(t: any, Fmt: any, cases: { any }, opts: any?): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- image(w, h, rgba string) -> Types.Image
|
||||
function R.image(w: number, h: number, rgba: string): Types.Image
|
||||
local img = Types.Image.new(w, h)
|
||||
img.pixels = buffer.fromstring(rgba)
|
||||
return img
|
||||
end
|
||||
|
||||
-- roundTrip(t, Fmt, img, encodeOpts?, label, tol?) -> the encoded buffer
|
||||
function R.roundTrip(t: any, Fmt: any, img: Types.Image, eopts: any?, label: string, tol: number?): buffer?
|
||||
local enc, err = Fmt.encode(img, eopts)
|
||||
t:check(enc, label .. ": encode " .. tostring(err))
|
||||
@@ -64,7 +59,6 @@ function R.roundTrip(t: any, Fmt: any, img: Types.Image, eopts: any?, label: str
|
||||
return enc
|
||||
end
|
||||
|
||||
-- samples(cases, every?) -> the fuzz samples (every n-th case's data)
|
||||
function R.samples(cases: { any }, every: number?): { string }
|
||||
local samples = {}
|
||||
for i, c in cases do
|
||||
|
||||
Reference in new issue
Block a user