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
-13
@@ -1,8 +1,4 @@
|
||||
-- image/gif tests: GIFs from ImageMagick and Pillow (static, interlaced, 2..256 colours, grey, transparency,
|
||||
-- animations with every disposal, sub-rectangles, local colour tables, loop counts, comments) against ImageMagick's
|
||||
-- decode of every frame; the encoder (lossless round trips at <= 256 colours, quantized PSNR above, animations with
|
||||
-- frames / delays / disposal / transparency / loops, options); error codes; the fuzz no-throw pass.
|
||||
-- Fixtures: tools/fixtures/gif.py.
|
||||
-- image/gif tests against ImageMagick's decodes (tools/fixtures/gif.py).
|
||||
local T = require("@tests/T")
|
||||
local Gif = require("@rosetta/image/gif")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -31,12 +27,10 @@ local function norm(px: buffer): buffer
|
||||
return c
|
||||
end
|
||||
|
||||
-- the contract
|
||||
t:eq(Gif.name, "gif", "name")
|
||||
t:eq(Gif.category, "image", "category")
|
||||
t:check(Gif.caps.decode and Gif.caps.encode and Gif.caps.animation, "caps")
|
||||
|
||||
-- every fixture against ImageMagick
|
||||
local nframes = 0
|
||||
for _, c in Fx do
|
||||
local img, err = decode(c.data)
|
||||
@@ -69,7 +63,6 @@ for _, c in Fx do
|
||||
end
|
||||
t:note("%d files, %d frames match ImageMagick", #Fx, nframes)
|
||||
|
||||
-- sniff, meta, limits, errors
|
||||
do
|
||||
local c = Fx[1]
|
||||
t:eq(Gif.sniff(Bytes.reader(buffer.fromstring(c.data))), 1, "sniff a GIF")
|
||||
@@ -100,7 +93,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- the encoder
|
||||
local rand = T.rng(17)
|
||||
local function image(w: number, h: number, colors: number?, alpha: boolean?): Types.Image
|
||||
local img = Types.Image.new(w, h)
|
||||
@@ -161,7 +153,6 @@ do
|
||||
local small = Gif.encode(photo, { maxColors = 4 }) :: buffer
|
||||
local sb = decode(small)
|
||||
t:check(sb.meta.palette and #sb.meta.palette <= 4, "maxColors = 4")
|
||||
-- animation: frames, delays, disposal, transparency, loops, comment, local / global palettes
|
||||
local anim = image(40, 30, 50)
|
||||
anim.frames = {
|
||||
{ image = image(40, 30, 50), x = 0, y = 0, delay = 0.1, dispose = "none", blend = "source" },
|
||||
@@ -189,9 +180,7 @@ do
|
||||
t:check(psnr(back.frames[3].image.pixels, anim.frames[3].image.pixels) > 25, "frame 3 quantized")
|
||||
t:eq(back.meta.source.localPalettes, if global then 0 else 3, "palettes")
|
||||
end
|
||||
-- deterministic output
|
||||
t:eq(Crc32.of(Gif.encode(photo, { dither = true }) :: buffer), Crc32.of(Gif.encode(photo, { dither = true }) :: buffer), "deterministic")
|
||||
-- bad arguments
|
||||
local _, e = Gif.encode({} :: any)
|
||||
t:check(e and e.code == Err.ARG, "encode of a non-image")
|
||||
local _, e2 = Gif.encode(photo, { maxColors = 1 })
|
||||
@@ -202,7 +191,6 @@ do
|
||||
t:check(e4 and e4.code == Err.ARG, "too wide")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx do
|
||||
|
||||
Reference in new issue
Block a user