tests/core: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:49:47 -05:00
1 parent e23adf2a2d
commit 53aa9a6ebf
4 files changed
+3 -24

No files matched your search

+1 -8
View File
@@ -1,6 +1,4 @@
-- core/Bits and codecs/entropy/Huffman tests: LSB / MSB readers and writers round-trip random fields of 1..32 bits, align /
-- peek / bytePos, overrun is a sticky error; canonical codes, length-limited code lengths, LSB and MSB decoding tables
-- (with subtables) decode what the writers wrote; invalid code sets are rejected.
-- core/Bits and codecs/entropy/Huffman tests: bit readers / writers, canonical codes, length limits, decoding tables.
local T = require("@tests/T")
local Bits = require("@rosetta/core/Bits")
local Huffman = require("@rosetta/codecs/entropy/Huffman")
@@ -9,7 +7,6 @@ local Err = require("@rosetta/core/Err")
local t = T.suite("bits")
local rand = T.rng(7)
-- round trips
for _, kind in { "lsb", "msb" } do
local w = if kind == "lsb" then Bits.lsbWriter() else Bits.msbWriter()
local fields = {}
@@ -46,7 +43,6 @@ for _, kind in { "lsb", "msb" } do
t:check(r.err and r.err.code == Err.TRUNCATED, kind .. ": overrun is TRUNCATED")
end
-- known bit orders
do
local lsb = Bits.lsbReader(T.bytes({ 0xB4 })) -- 1011 0100
t:eq(lsb:read(3), 4, "lsb: first field is the low bits")
@@ -83,7 +79,6 @@ do
t:eq(Huffman.reverse(1, 3), 4, "reverse 3 bits")
end
-- lengths: limits, Kraft equality, single symbol
local function kraft(lens: { number }): number
local s = 0
for _, l in lens do
@@ -113,7 +108,6 @@ do
t:check(u[1] == 2 and u[4] == 2, "uniform")
end
-- decoding tables: random code sets, encode with the writer, decode through LSB and MSB tables
for trial = 1, 30 do
local nsym = 2 + rand(300)
local freqs = {}
@@ -161,7 +155,6 @@ for trial = 1, 30 do
end
end
-- invalid code sets
do
local over = T.bytes({ 1, 1, 1 }) -- three 1-bit codes
t:eq(Huffman.buildLsb(over, 0, 3, buffer.create(1024 * 4), 8), -1, "over-subscribed")