tests/codecs (a-m): comments: specs only
This commit is contained in:
1 parent
a80299dce0
commit
5f7f6005f6
24 files changed
+46
-181
No files matched your search
@@ -1,7 +1,5 @@
|
||||
-- codecs/compress/Deflate tests: every fixture case (Python zlib, levels 0-9, every strategy, small windows, flushes, gzip
|
||||
-- headers, multi-member gzip) decodes; exact-size mode; checksum vectors; the compressor round-trips every corpus at
|
||||
-- every level (and its zlib / gzip framing); truncated / corrupted / random input returns nil, Err and never throws.
|
||||
-- Ported from deflate-luau tests/inflate.luau. Fixtures: tools/fixtures/deflate.py.
|
||||
-- codecs/compress/Deflate tests: Python zlib streams (levels 0-9, every strategy, gzip), the compressor round trips.
|
||||
-- Fixtures: tools/fixtures/deflate.py.
|
||||
local T = require("@tests/T")
|
||||
local Deflate = require("@rosetta/codecs/compress/Deflate")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -19,7 +17,6 @@ local function decode(kind: string, b: buffer, ...: any): (buffer?, any)
|
||||
end
|
||||
end
|
||||
|
||||
-- checksum vectors
|
||||
t:eq(Deflate.crc32("123456789"), 0xCBF43926, "crc32 check value")
|
||||
t:eq(Deflate.crc32(""), 0, "crc32 empty")
|
||||
t:eq(Deflate.adler32("Wikipedia"), 0x11E60398, "adler32 Wikipedia")
|
||||
@@ -35,7 +32,6 @@ do
|
||||
t:eq(Deflate.crc32(b, 3, 17), Deflate.crc32(string.sub(s, 4, 20)), "crc32 range")
|
||||
end
|
||||
|
||||
-- every case decodes to its corpus
|
||||
local nbytes = 0
|
||||
for _, c in Fx.cases do
|
||||
local want = Fx.corpora[c.corpus]
|
||||
@@ -65,10 +61,8 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d fixture streams, %.1f MB decoded", #Fx.cases, nbytes / 1e6)
|
||||
|
||||
-- strings are accepted
|
||||
t:check(buffer.tostring((Deflate.zlib(Fx.cases[25].data))) == Fx.corpora[Fx.cases[25].corpus], "string input")
|
||||
|
||||
-- corrupted checksums
|
||||
do
|
||||
local z
|
||||
for _, c in Fx.cases do
|
||||
@@ -93,7 +87,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- hand-made streams
|
||||
do
|
||||
local bytes = T.bytes
|
||||
-- stored block "hi" then a fixed block with only end-of-block
|
||||
@@ -148,7 +141,6 @@ do
|
||||
t:check(e and e.code == Err.ARG, "bad level returns Err.ARG")
|
||||
end
|
||||
|
||||
-- truncation, corruption and garbage never throw
|
||||
do
|
||||
local samples = {}
|
||||
local kinds = {}
|
||||
|
||||
Reference in new issue
Block a user