Formats: add 7 invariant unit tests for xma/tables.rs #1075
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#1075
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@geiyiliyabumo on GitHub · 2026-11-24 15:29 UTC · original
Summary
Audits all 16 Huffman/VLC/frequency tables in
crates/victory-formats/src/xma/tables.rs(previously 0 unit tests) and adds 7 deterministic invariant unit tests (plus#[rustfmt::skip]on the compact table literals). Table values are unchanged.Because external PR creation is currently restricted (
collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:geiyiliyabumo/VIctory@test/formats-xma-tablesgeiyiliyabumo/VIctory@d3867e6(based onmainffe310e)Tests Added (
crates/victory-formats/src/xma/tables.rs, +7 tests)2^32, ordering, alignment, first-code-zero).Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --check crates/victory-formats/src/xma/tables.rs: PASScargo xtask policy: PASS (154 files ok)cargo clippy -p victory-formats --all-targets --locked -- -D warnings: PASS (0 warnings)cargo test -p victory-formats --locked -- xma::: 12 passed, 0 failed (2 pre-existing ignored)AI-assisted; synthetic tests only, no game files.
@studiostephe on GitHub · 2026-11-25 03:36 UTC · original
tables.rsstill has no unit tests onmain(the fork branch in the issue was based onffe310e). I added the 7 invariant tests directly on current940d32f, test-only, table values untouched.What the 7 tests pin down (all derived from how
xma.rsconsumes the tables, not guessed):SCALE,SCALE_RL,COEF1are complete 32-bit canonical prefix codes (Kraft sum = 2³²) with unique symbols — the decoder indexes level tables by symbol, so a gap or repeat reads the wrong band.COEF0(symbols + lengths split) is a complete 32-bit code whose symbols are a permutation of0..272.VEC2andVEC1are complete 16-bit codes;VEC1's symbols are a permutation of0..101.VEC4is a complete 16-bit code and its symbols (minus the decoder's-1escape) decompose into four 4-bit nibbles, no two entries sharing a nibble combination (the decoder unpacks them straight into the four coefficients).CRITICAL_FREQis strictly ascending, 28 entries, last under the 64 kHz ceiling.1 << (bits - len)in the canonical walk andpeek32 >> (32 - len)in the decoder alike).Verified (native, this Mac,
victory-formats):cargo test -p victory-formats --locked -- xma::tables→ 7 passed, 0 failed.cargo clippy -p victory-formats --locked: 0 warnings.COEF0_SYMSentry (making it duplicate another) failsthe_coef0_code_is_complete_and_a_permutation_of_its_range.Not covered: I did not reformat the pre-existing table literals —
tables.rsis already rustfmt-dirty on cleanmain(the issue's#[rustfmt::skip]is therefore moot), and reflowing the tables would bloat the diff. My added test region is fmt-clean on its own.Local commit
d090fc5on a clean940d32f(one file, +179, test-only).qwen3.8_27b running locally on an M1 Mac
shout out to Digital Debris Los Angeles
@Marvisak on GitHub · 2026-11-25 10:00 UTC · original
Automated triage for the maintainers.
Test-only change, in scope.
crates/victory-formats/src/xma/tables.rsonmain(940d32f) still has no tests of its own. The change is now open as PR #1205 from the same author, so review goes there.@studiostephe's version of the same seven tests on current
main(d090fc5) is a local commit; if #1205 does not apply cleanly tomain, the two of you could bring it onto #1205 rather than opening a second PR for the same tests.Generated by Claude Code