diff --git a/tests/codecs/mdct.luau b/tests/codecs/mdct.luau index 2ad003b..c49765d 100644 --- a/tests/codecs/mdct.luau +++ b/tests/codecs/mdct.luau @@ -1,6 +1,5 @@ --- codecs/audio/Mdct tests: the FFT against a direct DFT for mixed-radix sizes, the forward / inverse MDCT and the DCT-IV --- against their O(N^2) definitions (AAC, Vorbis and CELT sizes), perfect reconstruction (TDAC) with the sine, KBD and --- Vorbis windows, window power complementarity, bad sizes. No fixtures (the definitions are the reference). +-- codecs/audio/Mdct tests: the FFT, MDCT and DCT-IV against their O(N^2) definitions, TDAC with every window. +-- No fixtures: the definitions are the reference. local T = require("@tests/T") local Mdct = require("@rosetta/codecs/audio/Mdct") @@ -16,7 +15,6 @@ local function noise(n: number): { number } return a end --- FFT vs DFT for _, n in { 1, 2, 3, 4, 5, 6, 7, 8, 12, 15, 16, 30, 49, 60, 64, 120, 240, 480, 77 } do local plan = Mdct.fft(n) t:check(plan, "fft plan " .. n) @@ -39,7 +37,6 @@ for _, n in { 1, 2, 3, 4, 5, 6, 7, 8, 12, 15, 16, 30, 49, 60, 64, 120, 240, 480, t:check(err < 1e-9 * n, string.format("fft %d: max error %g", n, err)) end --- MDCT / IMDCT vs the definitions local maxErr = 0 for _, n in { 4, 8, 16, 64, 240, 256, 480, 1920, 2048 } do local plan = Mdct.new(n) :: Mdct.Plan @@ -127,7 +124,6 @@ do t:check(e < 1e-10, "dct4 involution: " .. e) end --- bad sizes t:check(Mdct.new(6) == nil and Mdct.new(0) == nil and Mdct.new(-8) == nil and Mdct.new(8.5) == nil and Mdct.new("x" :: any) == nil, "bad mdct sizes") t:check(Mdct.fft(0) == nil and Mdct.window("nope", 8) == nil and Mdct.window("sine", 7) == nil, "bad fft sizes / windows") diff --git a/tests/codecs/minecraft.luau b/tests/codecs/minecraft.luau index 25f2557..04cd922 100644 --- a/tests/codecs/minecraft.luau +++ b/tests/codecs/minecraft.luau @@ -1,6 +1,4 @@ --- codecs/model/Minecraft tests: packed index arrays (spanning and not, 1..16 bits, against a bit-by-bit reference), --- Sponge varints, nibble arrays, YZX reordering, block-state strings and their NBT form, every legacy id / data pair --- through legacyState / legacyId, colours (air, families, fallbacks), voxels / blocksOf and nearest-colour blocks. +-- codecs/model/Minecraft tests: packed arrays, varints, nibbles, block states, legacy ids, colours, voxels. -- The formats using it: tests/model/schematic.luau, tests/model/mca.luau. local T = require("@tests/T") local Mc = require("@rosetta/codecs/model/Minecraft") @@ -10,7 +8,7 @@ local t = T.suite("minecraft") local P = Mc.Packed local rand = T.rng(3) --- 1. packed arrays against a reference that walks the bits one at a time +-- packed arrays against a reference that walks the bits one at a time local function refBit(longs: buffer, p: number): number return bit32.extract(buffer.readu8(longs, p // 8), p % 8, 1) end @@ -52,7 +50,6 @@ do t:eq(P.bitsFor(1, 2), 2, "bitsFor minimum") end --- 2. varints, nibbles, YZX do local idx = buffer.create(400) for i = 0, 199 do @@ -84,7 +81,6 @@ do t:eq(buffer.tostring(P.toYzx(vox, sx, sy, sz)), buffer.tostring(yzx), "toYzx") end --- 3. states do local name, props = Mc.parseState("oak_log[axis=y, foo = bar]") t:eq(name, "minecraft:oak_log", "namespace added") @@ -97,7 +93,7 @@ do t:check(Mc.isAir("minecraft:cave_air") and not Mc.isAir("minecraft:stone"), "isAir") end --- 4. legacy ids: every id / data pair reads back exactly +-- legacy ids: every id / data pair reads back exactly do local bad = 0 for id = 0, 255 do @@ -116,7 +112,6 @@ do t:eq(select(1, Mc.legacyId("minecraft:white_concrete")), 251, "modern name -> legacy id") end --- 5. colours do t:eq(Mc.color("minecraft:air"), nil, "air") local function hex(s: string): string @@ -132,7 +127,6 @@ do t:eq(hex("mod:something_odd"), "909090ff", "fallback") end --- 6. voxels / blocksOf do local states = { "minecraft:air", "minecraft:stone", "minecraft:red_wool", "minecraft:stone" } local idx = buffer.create(8 * 2) diff --git a/tests/codecs/mpeg1.luau b/tests/codecs/mpeg1.luau index b0fe7a8..ccc48cd 100644 --- a/tests/codecs/mpeg1.luau +++ b/tests/codecs/mpeg1.luau @@ -1,12 +1,5 @@ --- codecs/video/Mpeg1 tests, ported from mpeg1-luau tests/decode.luau and tests/robust.luau. Every frame bit-exact with --- `ffmpeg -idct int` (the IDCT codecs/video/Dsp reproduces; frames with concealed macroblocks excepted). Against ffmpeg --- (tools/fixtures/mpeg1.py): every stream decodes, one access unit at a time, to as many frames as ffmpeg's decode, --- in display order; each frame's RGBA channel means within 1.5 of ffmpeg's; whole sampled frames within 2 MAE per --- channel (IDCT and colour rounding) and, as yuv420p (frameImage), within a PSNR floor of ffmpeg -pix_fmt yuv420p; --- the same stream written in random pieces through write() / decodeFrame() gives identical frames; a size change. --- Robustness / API: bad arguments, pictures before the first sequence header, reset(), rgba = false, tags through --- B-frame reordering, string input, truncated units, bit flips and garbage (never throws, recovers at an --- I-picture), an oversized sequence header; frameImage; the fuzz no-throw pass. +-- codecs/video/Mpeg1 tests: every frame bit-exact with `ffmpeg -idct int` (concealed macroblocks excepted), the API. +-- Fixtures: tools/fixtures/mpeg1.py. local T = require("@tests/T") local Mpeg1 = require("@rosetta/codecs/video/Mpeg1") local Base64 = require("@rosetta/core/Base64") @@ -43,7 +36,6 @@ local function z64(s: string): buffer return Deflate.zlib(b64(s)) :: buffer end --- mean absolute error per channel (r, g, b) between two RGBA8 buffers of n pixels, and the largest difference local function mae(a: buffer, b: buffer, n: number): (number, number, number, number) local sr, sg, sb, mx = 0, 0, 0, 0 for i = 0, n - 1 do @@ -86,7 +78,6 @@ local MAE_LIMIT = 2 local totalExact, totalConcealed = 0, 0 local MEAN_LIMIT = 1.5 --- 1. every stream against ffmpeg local worst, worstY, worstC = 0, 99, 99 for _, fx in STREAMS do local name = fx.name @@ -211,7 +202,7 @@ end t:note("worst sampled-frame MAE %.3f (limit %d); worst yuv420p PSNR luma %.1f, chroma %.1f dB", worst, MAE_LIMIT, worstY, worstC) t:note("%d frames bit-exact with ffmpeg -idct int, %d with concealed macroblocks (ffmpeg error concealment)", totalExact, totalConcealed) --- 2. a size change mid-stream +-- a size change mid-stream do local file = b64(SizeChange.file) local dec = Mpeg1.new() @@ -235,7 +226,6 @@ do end end --- 3. robustness and the API local function slice(b: buffer, from: number, n: number): buffer local out = buffer.create(n) buffer.copy(out, 0, b, from, n) @@ -254,7 +244,7 @@ do t:eq(#ref, #main.units, "reference decode") end -do -- bad arguments +do local dec = Mpeg1.new() t:check(dec:decode((nil :: any)) == nil, "decode(nil)") t:check(dec:decode((42 :: any)) == nil, "decode(number)") @@ -488,7 +478,7 @@ do -- a hostile sequence header: a huge size is rejected t:eq(dec.width, 0, "oversized sequence header rejected") end --- 4. the fuzz pass: whole elementary streams (cut, mutated, garbage) through one decoder each +-- the fuzz pass: whole elementary streams (cut, mutated, garbage) through one decoder each do local samples = {} for _, k in { 1, 9 } do diff --git a/tests/codecs/mpeg2.luau b/tests/codecs/mpeg2.luau index 9b98e12..9385dde 100644 --- a/tests/codecs/mpeg2.luau +++ b/tests/codecs/mpeg2.luau @@ -1,10 +1,5 @@ --- codecs/video/Mpeg2 tests. Against `ffmpeg -idct int` (tools/fixtures/mpeg2.py): every stream (progressive and --- interlaced frame pictures with field prediction and field DCT, top / bottom field first, 4:2:2, the alternate scan, --- Table B-15, the non-linear quantiser scale, DC precision 9..11, custom luma / chroma matrices, f_code > 1, an odd --- size, B-frames, dual prime, field pictures, concealment vectors) decodes one access unit at a time to exactly ffmpeg's planes, every frame, in display --- order; the same stream written in random pieces gives the same frames; frame flags (mpeg2, chroma, progressive, --- topFieldFirst); frameImage (4:2:2 -> yuv420p, rgba8); the registry's VideoCodecDecoder; truncated and corrupted --- streams never throw; the fuzz no-throw pass. +-- codecs/video/Mpeg2 tests: every stream decodes to exactly `ffmpeg -idct int`'s planes, every frame, display order. +-- Fixtures: tools/fixtures/mpeg2.py. local T = require("@tests/T") local Mpeg2 = require("@rosetta/codecs/video/Mpeg2") local Video = require("@rosetta/codecs/video/Video") @@ -35,7 +30,6 @@ local function b64(s: string): buffer return Base64.decode(s) :: buffer end --- CRC-32 of a plane cropped to w x h from a buffer with stride local function planeCrc(b: buffer, stride: number, w: number, h: number): number local row = buffer.create(w * h) for y = 0, h - 1 do @@ -44,7 +38,6 @@ local function planeCrc(b: buffer, stride: number, w: number, h: number): number return Crc32.of(row) end --- the cropped planes of a frame, as ffmpeg writes them (w x h luma, ceil(w / 2) x (h or ceil(h / 2)) chroma) local function crcs(f: any): (number, number, number) local w, h = f.width, f.height local cw = (w + 1) // 2 @@ -53,7 +46,6 @@ local function crcs(f: any): (number, number, number) return planeCrc(f.y, f.codedWidth, w, h), planeCrc(f.cb, chw, cw, ch), planeCrc(f.cr, chw, cw, ch) end --- differing samples between a frame's luma and a reference yuv frame (debug detail on a mismatch) local function lumaDiff(f: any, ref: buffer): (number, number) local n, first = 0, -1 for y = 0, f.height - 1 do @@ -103,9 +95,8 @@ local function decodeUnits(fx: any, file: buffer): { any } return out end --- 1. every stream against ffmpeg, bit-exact. ffmpeg's encoder sometimes ends a B-picture slice before the row's last --- macroblock (invalid MPEG-2); both decoders conceal the gap, ffmpeg with its error-resilience guesses and deblocking. --- Frames with concealed macroblocks compare every 16-line luma band but those and their neighbours. +-- ffmpeg's encoder sometimes ends a B-picture slice before the row's last macroblock (invalid MPEG-2); both decoders +-- conceal the gap differently, so frames with concealed macroblocks skip those 16-line luma bands and their neighbours. local total, concealedFrames = 0, 0 for _, fx in STREAMS do local name = fx.name @@ -154,7 +145,6 @@ for _, fx in STREAMS do if fx.chroma == 2 then "4:2:2" else "4:2:0", #got, #got / dt) end --- 2. interlace flags do local got = decodeUnits(STREAMS[2], b64(STREAMS[2].file)) t:check(got[1][4].progressive == false and got[1][4].topFieldFirst == true, "tff: interlaced, top field first") @@ -164,7 +154,7 @@ do t:check(got[1][4].progressive == true, "prog: progressive") end --- 3. the same stream written in random pieces (decodeFrame) gives the same frames as unit by unit +-- the same stream written in random pieces (decodeFrame) gives the same frames as unit by unit for _, idx in { 2, 9, 12 } do local fx = STREAMS[idx] local file = b64(fx.file) @@ -200,7 +190,6 @@ for _, idx in { 2, 9, 12 } do t:check(ok and k == fx.frames, string.format("%s: random pieces give the same %d frames (%d)", fx.name, fx.frames, k)) end --- 4. frameImage: yuv420p (4:2:2 converted), rgba8 do local fx = STREAMS[9] local dec = Mpeg2.new({ reorder = false, rgba = true }) @@ -222,7 +211,7 @@ do t:check(Mpeg2.frameImage({} :: any) == nil, "frameImage of a non-frame is nil") end --- 5. the registry's decoder (packets = access units), display order with pts +-- the registry's decoder (packets = access units), display order with pts do t:check(Video.fromFourcc("mpg2") == "mpeg2" and Video.fromMatroska("V_MPEG2") == "mpeg2", "registry names") t:check(Video.canDecode("mpeg2") and Video.canDecode("mpeg1"), "registry decoders") @@ -256,7 +245,6 @@ do t:check(order, "registry decoder: frames in display order, equal to the codec's") end --- 6. robustness: truncated units, bit flips, garbage (never throws), and the fuzz pass do local samples = {} for _, idx in { 1, 2, 9, 11 } do diff --git a/tests/codecs/musepack.luau b/tests/codecs/musepack.luau index 530157b..fe3d352 100644 --- a/tests/codecs/musepack.luau +++ b/tests/codecs/musepack.luau @@ -1,7 +1,5 @@ --- codecs/audio/Musepack tests: the codec API under audio/mpc: magic, the stream fields of SV7 / SV8 fixtures (version, --- rate, channels, band count, packet layout, gapless length), packets decoded by hand against libmpcdec (the --- synthesis delay at the front), out-of-order decodes, and a fuzz pass over open + every packet. Fixtures: --- tools/fixtures/mpc.py. +-- codecs/audio/Musepack tests: SV7 / SV8 stream fields, packets against libmpcdec (synthesis delay at the front). +-- Fixtures: tools/fixtures/mpc.py. local T = require("@tests/T") local Musepack = require("@rosetta/codecs/audio/Musepack") local Fx = require("@tests/gen/mpc_cases") diff --git a/tests/codecs/nbt.luau b/tests/codecs/nbt.luau index 4da181e..df83f42 100644 --- a/tests/codecs/nbt.luau +++ b/tests/codecs/nbt.luau @@ -1,7 +1,4 @@ --- codecs/text/Nbt tests: random trees written by Python's nbtlib (Java big-endian, Bedrock little-endian, gzip, zlib, --- the level.dat header) decode to nbtlib's typed values (a canonical dump), re-encode to nbtlib's exact bytes in both --- byte orders, nbtlib's SNBT (indented and compact) parses to the same values and our SNBT reads back exactly; --- Bedrock network varint NBT; modified UTF-8; long extremes; SNBT grammar details; peek; errors; the fuzz pass. +-- codecs/text/Nbt tests: random trees by Python's nbtlib (Java / Bedrock, gzip, zlib) decode, re-encode exactly, SNBT. -- Fixtures: tools/fixtures/nbt.py. local T = require("@tests/T") local Nbt = require("@rosetta/codecs/text/Nbt") @@ -68,7 +65,6 @@ local function same(a: buffer, b: string): boolean return buffer.tostring(a) == b end --- 1. nbtlib trees for _, c in Fx.cases do local v, info = Nbt.decode(c.raw) t:check(v ~= nil, c.name .. ": decode " .. tostring(info)) @@ -87,7 +83,6 @@ for _, c in Fx.cases do t:eq(wi.endian, if k == "little" or k == "header" then "little" else "big", c.name .. ": " .. k .. " endian") end t:eq(wi.compression, if k == "gzip" or k == "zlib" then k else "none", c.name .. ": " .. k .. " compression") - -- written back the same way it was read local again = Nbt.encode(w) :: buffer local w2, wi2 = Nbt.decode(again) t:eq(canon(w2), c.canon, c.name .. ": " .. k .. " round trip") @@ -116,7 +111,6 @@ for _, c in Fx.cases do end end --- 2. Bedrock network NBT for i, c in Fx.net do local v, info = Nbt.decode(c.data, { varint = true }) t:check(v ~= nil, "net " .. i .. ": " .. tostring(info)) @@ -124,7 +118,6 @@ for i, c in Fx.net do t:check(same(Nbt.encode(v, { varint = true }) :: buffer, c.data), "net " .. i .. ": same bytes") end --- 3. details do -- longs: exact past 2^53, both directions for _, s in { "9223372036854775807", "-9223372036854775808", "9007199254740993", "-9007199254740993", "4294967296", "-1" } do @@ -155,14 +148,12 @@ do t:eq(tostring(Nbt.byte(3)), "3b", "tostring byte") t:eq(tostring(Nbt.float(0.1)), "0.1f", "tostring float (shortest)") t:check(Nbt.short(5) == Nbt.short(5) and Nbt.short(5) ~= Nbt.int(5) :: any, "tag equality") - -- get local g = assert(Nbt.parse("{Data:{Pos:[1.0d,2.5d,3.0d],Inv:[{id:\"x\"}]}}")) t:eq(Nbt.get(g, "Data.Pos[1]").value, 2.5, "get list element") t:eq(Nbt.get(g, "Data.Inv[0].id"), "x", "get nested") t:eq(Nbt.get(g, "Data.Missing.x"), nil, "get missing") end --- 4. SNBT grammar do local cases: { { string } } = { { "1b", "byte:1" }, { "-5S", "short:-5" }, { "7", "int:7" }, { "7i", "int:7" }, { "1_000", "int:1000" }, @@ -200,7 +191,6 @@ do t:check(e3 and e3.code == Err.LIMIT, "depth limit") end --- 5. peek do local c = Fx.cases[2] for _, k in { "raw", "gzip", "zlib", "header" } do @@ -210,7 +200,6 @@ do t:eq(Nbt.peek(buffer.fromstring("hello world")), nil, "peek text") end --- 6. errors do local _, e = Nbt.decode("\10\0\0\1\0\1a") t:check(e and e.code == Err.TRUNCATED, "truncated") @@ -233,7 +222,6 @@ do t:check(e6 and e6.code == Err.ARG, "encode function") end --- 7. fuzz local samples = {} for i = 1, 8 do table.insert(samples, Fx.cases[i].raw) diff --git a/tests/codecs/packbits.luau b/tests/codecs/packbits.luau index ceea442..3ae473e 100644 --- a/tests/codecs/packbits.luau +++ b/tests/codecs/packbits.luau @@ -1,5 +1,4 @@ --- codecs/compress/PackBits tests: the Apple technote example, encode -> decode round trips of random / runny rows, --- the clean flag on short input and overflowing runs, and a no-throw pass over garbage. +-- codecs/compress/PackBits tests: the Apple technote example, round trips, the clean flag, garbage. local T = require("@tests/T") local PackBits = require("@rosetta/codecs/compress/PackBits") diff --git a/tests/codecs/polygon.luau b/tests/codecs/polygon.luau index 4bd215e..6533fa0 100644 --- a/tests/codecs/polygon.luau +++ b/tests/codecs/polygon.luau @@ -1,5 +1,4 @@ --- codecs/model/Polygon tests: convex / concave / holed / nested polygons triangulate to the exact area in --- counter-clockwise triangles, either input orientation; degenerate loops; a fuzz of random loops never throws. +-- codecs/model/Polygon tests: polygons triangulate to the exact area in counter-clockwise triangles, degenerate loops. local T = require("@tests/T") local Polygon = require("@rosetta/codecs/model/Polygon") diff --git a/tests/codecs/quantize.luau b/tests/codecs/quantize.luau index 16a88dd..37ae3cd 100644 --- a/tests/codecs/quantize.luau +++ b/tests/codecs/quantize.luau @@ -1,6 +1,4 @@ --- codecs/image/Quantize tests: palette size bounds for every method and colour budget, the exact (lossless) palette at --- <= maxColors colours, transparency handling, PSNR of quantized images above thresholds, determinism of both --- methods and of Floyd-Steinberg dithering (the same CRC on both runtimes), bad arguments, and a no-throw pass. +-- codecs/image/Quantize tests: palette bounds, exact palettes, transparency, PSNR thresholds, determinism. local T = require("@tests/T") local Quantize = require("@rosetta/codecs/image/Quantize") local Crc32 = require("@rosetta/core/Crc32") @@ -43,7 +41,6 @@ end local W, H = 128, 96 local px = photo(W, H) --- palette bounds and quality local MIN_PSNR = { [256] = 30, [64] = 24, [16] = 17, [2] = 10 } for _, method in { "mediancut", "octree" } do for _, k in { 2, 16, 64, 256 } do @@ -66,7 +63,6 @@ for _, method in { "mediancut", "octree" } do end end --- exact palettes: lossless do local n = 50 * 40 local b = buffer.create(n * 4) @@ -84,7 +80,6 @@ do t:check(e3 and #p3 == 200 and buffer.tostring(render(i3, p3, n)) == buffer.tostring(b), "quantize() exact") end --- transparency do local b = buffer.create(16 * 4) for i = 0, 15 do @@ -112,7 +107,6 @@ do t:check(#o1 == #o2 and o1[#o1][1] == o2[#o2][1], "octree deterministic") end --- bad arguments never throw do t:eq(#Quantize.palette(nil :: any, 1, 1, 4), 0, "nil pixels") t:eq(#Quantize.palette(buffer.create(3), 1, 1, 4), 0, "short buffer") diff --git a/tests/codecs/raster.luau b/tests/codecs/raster.luau index 4aece49..f6757cb 100644 --- a/tests/codecs/raster.luau +++ b/tests/codecs/raster.luau @@ -1,7 +1,5 @@ --- codecs/image/Raster tests: exact coverage of axis-aligned rectangles at fractional positions; areas of circles; random --- polygons and curves under random transforms against an independent 12 x 12 supersampled winding-number reference --- (both fill rules); clipping, the stroker (width, caps, joins against analytic areas), fill() compositing and paint --- functions; malformed paths never throw. Glyph rendering against FreeType is in tests/font/ttf.luau. +-- codecs/image/Raster tests: coverage against a 12 x 12 supersampled winding reference, the stroker, fill(). +-- Glyph rendering against FreeType is in tests/font/ttf.luau. local T = require("@tests/T") local R = require("@rosetta/codecs/image/Raster") local Types = require("@rosetta/Types") @@ -27,7 +25,6 @@ local function at(m: any, x: number, y: number): number return buffer.readu8(m.coverage, j * m.width + i) end --- 1. rectangles: exact per-pixel coverage do local p = R.path():rect(1.25, 2.5, 3.5, 2) local m = R.mask(p) :: any @@ -54,7 +51,7 @@ for _, r in { 3, 10.5, 40 } do t:check(math.abs(a - math.pi * r * r) < 0.01 * math.pi * r * r + 1, string.format("circle r=%g area %.2f", r, a)) end --- 3. random paths against a supersampled winding reference +-- random paths against a supersampled winding reference local function wind(polys: { { number } }, px: number, py: number): number local w = 0 for _, poly in polys do @@ -143,7 +140,6 @@ do t:check(math.abs(sum(R.mask(q)) - 84) < 0.01, "nonzero hole with opposite winding") end --- 5. clipping: a shape larger than the clip, partly outside on every side do local m = R.mask(R.path():rect(-20.5, -3.25, 100, 50), { clip = { 0, 0, 16, 8 } }) :: any t:check(m and m.x == 0 and m.y == 0 and m.width == 16 and m.height == 8, "clipped bounds") @@ -178,7 +174,6 @@ do t:check(math.abs(a - 2 * math.pi * 10) < 1, "circle outline " .. a) end --- 7. fill onto an image: colours, opacity, paint functions, compositing over existing pixels do local img = Types.Image.new(8, 8) t:check(R.fill(img, R.path():rect(0, 0, 4, 8), { 255, 0, 0, 255 }), "fill red") @@ -208,7 +203,6 @@ do end) == false, "a failing paint function returns false") end --- 8. malformed paths and huge / non-finite coordinates never throw do local bad: { any } = { { { op = "moveTo" }, { op = "lineTo", 1 }, { op = "quadTo", 1, 2, "x", 4 }, { op = "close" } }, diff --git a/tests/codecs/resample.luau b/tests/codecs/resample.luau index 229c04b..5412cba 100644 --- a/tests/codecs/resample.luau +++ b/tests/codecs/resample.luau @@ -1,6 +1,4 @@ --- codecs/audio/Resample tests: sines through common rate pairs (44100 <-> 48000, 8000 -> 48000, 48000 -> 22050, an inexact --- ratio) against the analytic signal, alias rejection when downsampling, output lengths, streaming in odd chunks = --- the whole-buffer result, multichannel, a Pcm source wrapper, bad arguments, and a no-throw pass over garbage. +-- codecs/audio/Resample tests: sines against the analytic signal, alias rejection, streaming, a Pcm source. local T = require("@tests/T") local Resample = require("@rosetta/codecs/audio/Resample") local Pcm = require("@rosetta/codecs/audio/Pcm") @@ -19,7 +17,6 @@ local function sine(frames: number, ch: number, rate: number, freqs: { number }) return b end --- snr(out, frames, ch, rate, freqs, skip) -> dB of the analytic sine against the error, away from the edges local function snr(b: buffer, frames: number, ch: number, rate: number, freqs: { number }, skip: number): number local sig, err = 0, 0 for i = skip, frames - 1 - skip do @@ -42,7 +39,6 @@ local function rms(b: buffer, frames: number, skip: number): number return math.sqrt(s / math.max(1, frames - 2 * skip)) end --- 1. accuracy on in-band sines for _, c in { { 44100, 48000, 1000, "medium", 80 }, { 48000, 44100, 3000, "medium", 80 }, { 8000, 48000, 440, "medium", 80 }, { 48000, 22050, 5000, "high", 90 }, { 44100, 48000, 1000, "low", 55 }, { 44100, 47999, 1000, "medium", 75 } } do local from, to, f, q, want = c[1], c[2], c[3], c[4], c[5] local n = from // 4 @@ -65,7 +61,7 @@ do t:check(level < 1e-3, string.format("alias rejection: %.2e", level)) end --- 3. streaming in odd chunk sizes gives the whole-buffer result; stereo channels stay apart +-- streaming in odd chunk sizes gives the whole-buffer result; stereo channels stay apart do local n, ch = 10007, 2 local src = sine(n, ch, 44100, { 700, 1900 }) @@ -92,7 +88,6 @@ do t:check(snr(got, gf, ch, 48000, { 700, 1900 }, 500) > 80, "stereo accuracy") end --- 4. a codecs/audio/Pcm source at a new rate do local a = Types.Audio.new(22050, 1, 5000) a.samples = sine(5000, 1, 22050, { 500 }) @@ -103,7 +98,6 @@ do t:check(col and snr(col.samples, col.frames, 1, 32000, { 500 }, 300) > 80, "source accuracy") end --- 5. identity, empty input, bad arguments do local src = sine(1000, 1, 48000, { 1000 }) local out = Resample.buffer(src, 1000, 1, 48000, 48000) @@ -116,7 +110,6 @@ do t:check(Resample.buffer(buffer.create(4), 10, 1, 44100, 48000) == nil, "short buffer") end --- 6. no throw on garbage (NaN / Inf samples, odd lengths, chunk sizes) local samples = {} for i = 1, 4 do table.insert(samples, buffer.tostring(sine(100 * i, 1, 8000, { 300 }))) diff --git a/tests/codecs/rig.luau b/tests/codecs/rig.luau index e86a72c..c203d24 100644 --- a/tests/codecs/rig.luau +++ b/tests/codecs/rig.luau @@ -1,6 +1,4 @@ --- codecs/model/Rig tests: morph targets and weights animations from frames, skeletons in local and world space --- (node TRS, inverse bind matrices against Mat4), influences (top four, normalised), joint TRS animations; and --- Pixels.palette. +-- codecs/model/Rig tests: morph targets, skeletons (inverse bind matrices against Mat4), influences, Pixels.palette. local T = require("@tests/T") local Rig = require("@rosetta/codecs/model/Rig") local Mat4 = require("@rosetta/codecs/model/Mat4") @@ -21,7 +19,6 @@ local function near(a: number, b: number): boolean return math.abs(a - b) < 1e-5 end --- morph do local base = { 0, 0, 0, 1, 0, 0 } local prim: Types.Primitive = { attributes = { POSITION = Scene.accessor(f32s(base), "f32", 3, 2) }, mode = "points" } @@ -44,7 +41,6 @@ do t:eq(buffer.readf32(ch.output.data, (3 + 2) * 4), 1, "key 2 -> target 3") end --- skeleton do local q = Mat4.axisAngle(0, 0, 1, 90) local joints = { @@ -81,7 +77,6 @@ do t:eq(s.animations[ai].channels[1].node, nodes[2], "channel node") end --- palette do local pal = Pixels.palette(buffer.fromstring("\1\2\3\4\5\6"), 0, 2) t:eq(buffer.readu32(pal, 4), 0xFF060504, "rgb triples") diff --git a/tests/codecs/sampler.luau b/tests/codecs/sampler.luau index 6d66433..ef28e08 100644 --- a/tests/codecs/sampler.luau +++ b/tests/codecs/sampler.luau @@ -1,6 +1,4 @@ --- codecs/model/Sampler tests: STEP / LINEAR / CUBICSPLINE channels (glTF's Hermite definition), quaternion slerp --- (shortest path, unit length), clamping outside the keys, weights channels, Sampler.times and Sampler.pose; glTF's --- InterpolationTest sample model (every interpolation) sampled at its keys gives the key values; bad channels. +-- codecs/model/Sampler tests: STEP / LINEAR / CUBICSPLINE (glTF's Hermite definition), slerp, InterpolationTest. local T = require("@tests/T") local Sampler = require("@rosetta/codecs/model/Sampler") local Gltf = require("@rosetta/model/gltf") diff --git a/tests/codecs/theora.luau b/tests/codecs/theora.luau index c928965..3bee30c 100644 --- a/tests/codecs/theora.luau +++ b/tests/codecs/theora.luau @@ -1,11 +1,5 @@ --- codecs/video/Theora tests. Against ffmpeg (tools/fixtures/theora.py, its vp3 decoder = libtheora's output): every --- frame of every stream, bit-exact (Adler-32 of the native planes of the picture region, as ffmpeg's framecrc): 4:2:0 / --- 4:2:2 / 4:4:4, qualities 0..10, a 300 kbit/s high-motion stream (4MV, golden frames, multiple qi), picture regions --- smaller than the coded frame (even sizes from the encoder, odd sizes at offsets patched into the header), frames --- the encoder dropped (empty packets: ffmpeg outputs nothing, we repeat the previous picture) and one spliced in; --- image() as yuv420p (4:2:2 / 4:4:4 chroma averaged); Theora in Matroska through the codecs/video/Video registry. --- Errors: missing / bad headers, maxPixels, header packets in the data, garbage packets; the fuzz no-throw passes --- (headers, key and inter frames). +-- codecs/video/Theora tests: every frame bit-exact against ffmpeg's vp3 decoder (Adler-32 of planes, as framecrc). +-- Fixtures: tools/fixtures/theora.py. local T = require("@tests/T") local Theora = require("@rosetta/codecs/video/Theora") local Video = require("@rosetta/codecs/video/Video") @@ -33,7 +27,6 @@ local FIXTURES: { [string]: any } = { crop422 = require("@tests/gen/theora_crop422"), } --- the Theora packets of an Ogg file: headers, data packets local function packets(file: buffer): ({ buffer }, { buffer }) local d = Ogg.open(file) local serial = d:find("theora") @@ -58,7 +51,6 @@ end local samples: { buffer } = {} local headerSets: { { buffer } } = {} --- 1. every fixture, every frame for _, name in CASES do local fx = FIXTURES[name] local hdrs, data = packets(Base64.decode(fx.file) :: buffer) @@ -126,7 +118,6 @@ do t:eq(bad, 0, "dupe: the other frames") end --- 3. image(): yuv420p, the planes as they are (4:2:0) or averaged (4:2:2 / 4:4:4) for _, name in { "q6", "crop", "yuv422", "crop422", "odd444" } do local fx = FIXTURES[name] local hdrs, data = packets(Base64.decode(fx.file) :: buffer) @@ -164,7 +155,7 @@ for _, name in { "q6", "crop", "yuv422", "crop422", "odd444" } do t:eq(img.meta.yuv and img.meta.yuv.matrix, "bt601", name .. ": colour matrix") end --- 4. Theora in Matroska: the registry entry (V_THEORA, Xiph-laced CodecPrivate) through video/mkv +-- Theora in Matroska: the registry entry (V_THEORA, Xiph-laced CodecPrivate) through video/mkv do t:eq(Video.fromMatroska("V_THEORA"), "theora", "registry: V_THEORA") t:check(Video.canDecode("theora"), "registry: theora decodes") @@ -199,7 +190,6 @@ do end end --- 5. API details and errors do local fx = FIXTURES.q6 local hdrs, data = packets(Base64.decode(fx.file) :: buffer) @@ -261,7 +251,7 @@ do t:check(nv == nil and nerr ~= nil, "newVideoDecoder without config") end --- 6. fuzz: headers, keyframes and inter frames (a decoder primed with a keyframe, fed mutated packets) +-- fuzz: a decoder primed with a keyframe, fed mutated packets do local hdrs = headerSets[1] t:fuzz("headers", function(b: buffer) diff --git a/tests/codecs/unixcompress.luau b/tests/codecs/unixcompress.luau index 916d796..8e35af3 100644 --- a/tests/codecs/unixcompress.luau +++ b/tests/codecs/unixcompress.luau @@ -1,6 +1,5 @@ --- codecs/compress/UnixCompress tests: ncompress 5.0 files (widths 10..16, block mode, CLEAR codes after the ratio --- check, empty / one-byte / random inputs) decode to their inputs; compress() gives ncompress's bytes for the same input --- and width; non-block-mode streams; errors; the fuzz pass. Fixtures: tools/fixtures/z.py. +-- codecs/compress/UnixCompress tests: ncompress 5.0 files decode, compress() gives ncompress's bytes, errors. +-- Fixtures: tools/fixtures/z.py. local T = require("@tests/T") local UnixCompress = require("@rosetta/codecs/compress/UnixCompress") local Crc32 = require("@rosetta/core/Crc32") @@ -45,7 +44,6 @@ do t:eq(out and buffer.tostring(out), "ABABABA", "non-block mode") end --- errors do local _, e1 = UnixCompress.decompress("\31\157") t:check(e1 and e1.code == Err.TRUNCATED, "short header") diff --git a/tests/codecs/url.luau b/tests/codecs/url.luau index 20b5345..a1106b7 100644 --- a/tests/codecs/url.luau +++ b/tests/codecs/url.luau @@ -1,7 +1,5 @@ --- codecs/text/Url + codecs/text/Text tests: every example of RFC 3986 section 5.4 (normal and abnormal), dot-segment removal, --- splitting, encoding and the location helpers (ported from playlist-luau tests/url.luau); random references against --- Python's urllib.parse.urljoin; Url.locate / Url.base; Windows-1252 decoding against Python's cp1252 codec; lines, --- BOM, trim; the fuzz pass. Fixtures: tools/fixtures/playlist.py. +-- codecs/text/Url + Text tests: RFC 3986 5.4 examples, urljoin against Python's urllib, cp1252 against Python. +-- Fixtures: tools/fixtures/playlist.py. local T = require("@tests/T") local Url = require("@rosetta/codecs/text/Url") local Text = require("@rosetta/codecs/text/Text") @@ -62,13 +60,11 @@ eq(Url.scheme("HTTPS://x"), "https", "scheme lower-cased") eq(Url.scheme("music/a.mp3"), nil, "relative has no scheme") --- Python's urljoin for _, c in Ref do eq(Url.resolve(c[1], c[2]), c[3], "urljoin " .. c[1] .. " against " .. c[2]) end t:note("%d random references resolve as urllib.parse.urljoin", #Ref) --- locate / base do local w = {} local base, scheme = Url.base("https://h/a/list.m3u", w) @@ -82,7 +78,6 @@ do t:check(select(2, Url.base("C:\\Music\\l.m3u")) == "windows", "windows base") end --- Text do for _, c in Cp do eq(Text.toUtf8("x" .. string.char(c[1]) .. "y"), "x" .. c[2] .. "y", string.format("cp1252 0x%02x", c[1])) diff --git a/tests/codecs/vp8.luau b/tests/codecs/vp8.luau index 7ba6a3b..80bc411 100644 --- a/tests/codecs/vp8.luau +++ b/tests/codecs/vp8.luau @@ -1,7 +1,5 @@ --- codecs/image/Vp8 tests: the VP8 key frames of the WebP fixtures (cwebp at many settings and libvpx through ffmpeg, with --- 1..8 token partitions) decoded through the codec API: the yuv420p planes against dwebp -yuv, toRgba against --- dwebp -pam (fancy upsampling) and -nofancy, the decoder object over successive frames, headers, error codes and the --- fuzz no-throw pass on raw frames. Fixtures: tools/fixtures/webp.py. +-- codecs/image/Vp8 tests: WebP key frames: yuv420p against dwebp -yuv, toRgba against dwebp -pam and -nofancy. +-- Fixtures: tools/fixtures/webp.py. local T = require("@tests/T") local Vp8 = require("@rosetta/codecs/image/Vp8") local Crc32 = require("@rosetta/core/Crc32") @@ -50,7 +48,6 @@ for _, c in Cases do end t:note("%d VP8 key frames (%d from libvpx) match dwebp: planes, fancy and point upsampling", n, vpx) --- errors do local f = buffer.fromstring(frames[1]) local inter = buffer.fromstring(frames[1]) @@ -69,7 +66,6 @@ do t:check(e5 and e5.code == Err.ARG, "toRgba of a non-yuv image") end --- fuzz on raw frames t:fuzz("decodeFrame", function(b: buffer) return Vp8.decodeFrame(b, 0, buffer.len(b), { maxPixels = 2 ^ 20 }) end, frames, { mutations = 12, keepHeader = 10 }) diff --git a/tests/codecs/vp8l.luau b/tests/codecs/vp8l.luau index 2084a20..b032ba9 100644 --- a/tests/codecs/vp8l.luau +++ b/tests/codecs/vp8l.luau @@ -1,6 +1,4 @@ --- codecs/image/Vp8L tests: the VP8L bitstreams of the WebP fixtures (cwebp -z 0..9, -exact, near-lossless) decoded through --- the codec API against dwebp, the encoder at every effort on generated images (gradients, noise, palettes of 1..300 --- colours, odd sizes, alpha), headerless alpha streams, error codes, and the fuzz no-throw pass on raw bitstreams. +-- codecs/image/Vp8L tests: the WebP fixtures' VP8L (cwebp -z 0..9, -exact, near-lossless) against dwebp, the encoder. -- Fixtures: tools/fixtures/webp.py. local T = require("@tests/T") local Vp8L = require("@rosetta/codecs/image/Vp8L") @@ -10,7 +8,6 @@ local Cases = require("@tests/gen/webp_cases") local t = T.suite("vp8l") --- the VP8L chunk of a simple-format file local function chunk(data: string): (buffer?, number, number) if string.sub(data, 13, 16) ~= "VP8L" then return nil, 0, 0 @@ -40,7 +37,6 @@ for _, c in Cases do end t:note("%d VP8L bitstreams match dwebp", n) --- the encoder: round trips at every effort local rand = T.rng(5) local function gen(w: number, h: number, kind: string): buffer local px = buffer.create(w * h * 4) @@ -92,7 +88,6 @@ for _, kind in { "grad", "alpha", "noise", "pal1", "pal4", "pal40", "pal300" } d end t:note("%d encoder round trips", count) --- errors do local _, e1 = Vp8L.decode(buffer.fromstring("\x2e\0\0\0\0")) t:check(e1 and e1.code == Err.CORRUPT, "bad signature: " .. tostring(e1)) @@ -109,7 +104,6 @@ do t:check(e6 and e6.code == Err.ARG, "encode: short pixel buffer") end --- fuzz on raw bitstreams t:fuzz("decode", function(b: buffer) return Vp8L.decode(b, 0, buffer.len(b), 2 ^ 20) end, streams, { mutations = 10, keepHeader = 5 }) diff --git a/tests/codecs/vp8video.luau b/tests/codecs/vp8video.luau index 2ef1db9..5c3416f 100644 --- a/tests/codecs/vp8video.luau +++ b/tests/codecs/vp8video.luau @@ -1,8 +1,4 @@ --- codecs/image/Vp8 video tests: whole IVF streams through one decoder object, every shown frame bit-exact against ffmpeg's --- native vp8 decoder (yuv420p CRC32): the official VP8 test vectors (vp80-00-comprehensive-001..018 and others) and --- libvpx clips at many settings (alt-ref / hidden frames, golden, token partitions, error resilience, profiles 1-3, --- sharpness, segmentation, q extremes, short key frame intervals, motion off the frame, odd sizes). Also hidden --- frames, reset() and inter frames without a key frame, and the fuzz no-throw pass over damaged streams. +-- codecs/image/Vp8 video tests: VP8 test vectors and libvpx IVF clips bit-exact against ffmpeg's vp8 (yuv420p CRC32). -- Fixtures: tools/fixtures/vp8video.py. local T = require("@tests/T") local Vp8 = require("@rosetta/codecs/image/Vp8") @@ -12,7 +8,6 @@ local Cases = require("@tests/gen/vp8video_cases") local t = T.suite("vp8video") --- the frames of an IVF file: { offset, length } local function ivfFrames(b: buffer): { { number } } local out = {} local p = buffer.readu16(b, 6) -- header length (32) @@ -110,7 +105,6 @@ do t:check(e3 and e3.code == Err.TRUNCATED, "truncated frame tag: " .. tostring(e3)) end --- fuzz: whole damaged streams through one decoder (truncated / mutated frames after valid ones) local function feed(b: buffer) local dec = Vp8.newDecoder() local any = false diff --git a/tests/codecs/vrml.luau b/tests/codecs/vrml.luau index 0cb4f31..6f042c8 100644 --- a/tests/codecs/vrml.luau +++ b/tests/codecs/vrml.luau @@ -1,7 +1,4 @@ --- codecs/model/Vrml tests: the classic-encoding lexer and parser (comments, commas, string escapes, hex / exponent --- numbers, DEF / USE, PROTO with IS fields, nested PROTOs and ROUTEs in bodies, EXTERNPROTO, Script interfaces, --- IMPORT / EXPORT, the X3D header statements), the XML encoding's adapter (containerField, ProtoDeclare / --- ProtoInstance, IS / connect), typed field reads of raw XML attributes, detection, errors, the fuzz pass. +-- codecs/model/Vrml tests: the classic-encoding lexer and parser, the XML encoding's adapter, detection, errors. local T = require("@tests/T") local Vrml = require("@rosetta/codecs/model/Vrml") local Fields = require("@rosetta/codecs/model/Vrml/Fields") @@ -9,7 +6,6 @@ local Err = require("@rosetta/core/Err") local t = T.suite("vrml codec") --- ------------------------------------------------------------------------------------------------ lexer / parser do local g = assert(Vrml.parse([[#VRML V2.0 utf8 # a comment, then commas as blanks @@ -81,7 +77,6 @@ do t:eq(s.meta.unit, 0.3048, "UNIT length -> meta.unit") end --- ------------------------------------------------------------------------------------------------ XML adapter do local g = assert(Vrml.graph([[ @@ -111,7 +106,6 @@ do t:eq(Fields.strs(single, "url")[1], "plain name.png", "unquoted single MFString") end --- ------------------------------------------------------------------------------------------------ errors do local function code(text: string): string? local _, e = Vrml.graph(text) @@ -129,7 +123,6 @@ do t:eq(e and e.code, Err.ARG, "encode junk") end --- ------------------------------------------------------------------------------------------------ fuzz do local samples = { "#VRML V2.0 utf8\nPROTO P [ field SFFloat a 1 ] { Box { size IS a IS a } }\nDEF X P { a 2 } USE X ROUTE X.a TO X.b\n", diff --git a/tests/codecs/xml.luau b/tests/codecs/xml.luau index 69fd59e..65d688e 100644 --- a/tests/codecs/xml.luau +++ b/tests/codecs/xml.luau @@ -1,6 +1,4 @@ --- codecs/text/Xml tests: random documents (namespaces, escapes, CDATA, comments, PIs, DOCTYPE entities, UTF-16, Latin-1) --- against Python's ElementTree trees; encode -> decode round trips; well-formedness verdicts against expat --- (hand-written cases and random mutations); events, helpers, options, error codes; the fuzz pass. +-- codecs/text/Xml tests: random documents against Python's ElementTree, well-formedness against expat, the API. -- Fixtures: tools/fixtures/xml.py. local T = require("@tests/T") local Xml = require("@rosetta/codecs/text/Xml") @@ -53,7 +51,6 @@ local function canon(e: any, tail: string?): string return table.concat(out) .. ")t" .. s(tail) end --- 1. documents vs ElementTree, and round trips for i, d in Docs do local doc, err = Xml.decode(d.data, { whitespace = true }) t:check(doc, "doc " .. i .. ": " .. tostring(err)) @@ -74,7 +71,6 @@ for i, d in Docs do t:eq(root.ns, want, "doc " .. i .. ": node.ns") end --- 2. well-formedness against expat local agree, total, accepted, rejected = 0, 0, 0, 0 for i, c in Wf do local doc = Xml.decode(c.data) @@ -94,7 +90,6 @@ end t:note("well-formedness: %d of %d verdicts agree with expat (%d well-formed, %d not)", agree, total, accepted, rejected) t:check(agree >= total * 0.99, "well-formedness agreement >= 99%") --- 3. API details do local src = '\n]>\nt]]>u\n' local doc = Xml.decode(src, { comments = true, cdata = true, pi = true, namespaces = true }) :: any @@ -130,7 +125,6 @@ do local n = Xml.decode("l1\r\nl2\rl3") :: any t:eq(n.root.attrs.b, "x y z\n", "attribute value normalization") t:eq(Xml.text(n.root), "l1\nl2\nl3", "line endings") - -- builders and encode local e = Xml.element("svg", { width = "10", height = "5" }, { Xml.element("rect", { x = "1" }), "aa<b & "c"', "encode element") @@ -144,7 +138,6 @@ do local _, ce = Xml.encode(cyc) t:eq(ce and ce.code, Err.ARG, "cycle on encode") t:eq(Xml.encode({ name = "#cdata", attrs = Types.object(), children = {}, text = "a]]>b" } :: any), "b]]>", "cdata split") - -- events local evs = {} for ev, a in Xml.events("t") do table.insert(evs, ev .. (if type(a) == "string" then ":" .. a else "")) @@ -166,7 +159,6 @@ do t:eq(ue and ue.code, Err.UNSUPPORTED, "unsupported encoding") end --- 4. errors and limits local function code(src: string, opts: any?): string? local _, e = Xml.decode(src, opts) return e and e.code @@ -182,7 +174,6 @@ t:eq(code("", { namespaces = true }), Err.CORRUPT, "undeclared prefix") local _, ae = Xml.decode(5 :: any) t:eq(ae and ae.code, Err.ARG, "bad argument") --- 5. fuzz local samples = {} for i = 1, 40 do table.insert(samples, Docs[i].data) diff --git a/tests/codecs/yuv.luau b/tests/codecs/yuv.luau index 8b2d258..4036487 100644 --- a/tests/codecs/yuv.luau +++ b/tests/codecs/yuv.luau @@ -1,5 +1,4 @@ --- codecs/image/Yuv tests: scale (yuv420p planes resized bilinear: flat planes stay flat, a horizontal ramp stays a --- monotonic ramp, output sizes with odd dimensions, identity size, short input), imageScale, and a toRgba round trip. +-- codecs/image/Yuv tests: scale (bilinear yuv420p), imageScale, and a toRgba round trip. local T = require("@tests/T") local Yuv = require("@rosetta/codecs/image/Yuv") local Types = require("@rosetta/Types") @@ -48,7 +47,6 @@ for _, c in { { 64, 48, 32, 24 }, { 800, 600, 480, 360 }, { 33, 17, 13, 9 }, { 2 t:check(buffer.readu8(out, 0) <= 16 and buffer.readu8(out, dw - 1) >= 239, label .. ": ramp ends") end --- the same size copies local src = picture(20, 20) t:eq(buffer.tostring(Yuv.scale(src, 20, 20, 20, 20)), buffer.tostring(src), "identity") -- a short source gives a zero picture of the right size, no throw diff --git a/tests/codecs/zstd.luau b/tests/codecs/zstd.luau index 343aed3..b320d8b 100644 --- a/tests/codecs/zstd.luau +++ b/tests/codecs/zstd.luau @@ -1,7 +1,5 @@ --- codecs/compress/Zstd tests: every fixture case (the zstd CLI at levels 1..19, --ultra -22, --fast, --long, small windows, --- with / without checksum and content size, multi-frame and skippable frames, empty input) decodes to its corpus; --- offsets / consumedEnd; XXH64 vectors; checksum, limit and error codes; truncated / corrupted / random input never --- throws. Fixtures: tools/fixtures/zstd.py. +-- codecs/compress/Zstd tests: zstd CLI frames (levels 1..19, --ultra -22, --fast, --long) decode, XXH64, errors. +-- Fixtures: tools/fixtures/zstd.py. local T = require("@tests/T") local Zstd = require("@rosetta/codecs/compress/Zstd") local Err = require("@rosetta/core/Err") @@ -22,7 +20,6 @@ do t:eq(hex(string.rep("0123456789", 10)), "f80e7b96315afffa", "xxh64 100 bytes") end --- every case decodes to its corpus local nbytes = 0 for _, c in Fx.cases do local want = Fx.corpora[c.corpus] @@ -44,7 +41,6 @@ local function case(name: string): any error("no case " .. name) end --- at an offset inside a bigger buffer, and string input do local c = case("text/l3") local big = buffer.create(#c.data + 20) @@ -73,7 +69,6 @@ do t:check(out2 and buffer.tostring(out2) == Fx.corpora.text, "verify = false") end --- limits and arguments do local c = case("text/l3") local _, e = Zstd.decompress(c.data, nil, nil, { maxBytes = 1000 }) @@ -95,7 +90,6 @@ do t:check(e6 and e6.code == Err.CORRUPT, "reserved block type: " .. tostring(e6)) end --- truncation, corruption and garbage never throw do local samples = {} for i, c in Fx.cases do