test(victory-formats): pin the XMA Pro Huffman/level tables' invariants #611

Open
AnastasisKon wants to merge 1 commit from upstream-pr/611 into main
AnastasisKon commented 2026-11-28 13:21:45 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:21:45Z.


Test-only change: crates/victory-formats/src/xma/tables.rs held 16 constant tables (Huffman pairs, code lengths, run/level tables) with no tests.

What the tests pin

  • Every (symbol, code length) table — SCALE, SCALE_RL, COEF1, VEC2, VEC1, plus COEF0_SYMS/COEF0_LENS and VEC4_SYMS/VEC4_LENS zipped the way xma.rs consumes them — is a complete prefix code: walking the entries in code order with the same assignment xma::Vlc::new makes (code += 1 << (32 - len)) keeps every code in 32 bits, ends exactly at 1 << 32, has unique symbols and lengths in 1..=32.
  • CRITICAL_FREQ is strictly increasing.
  • Each run/level table matches its Huffman table's length, and all level values are finite.

Testing

  • cargo test -p victory-formats --lib xma::tables — 3 pass
  • cargo test -p victory-formats -p victory-hle -p victory -p victory-gpu -p xtask (host arm64) — all pass
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — clean
  • cargo xtask policy — 404 files ok

Checklist

  • One change, one PR
  • Branch vibe/xma-tables-tests-1705ac from upstream/main, pushed to my fork only
  • No game/GDK files, no dumps/logs in the repo
  • No AI attribution in the diff
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5540548246 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/611). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:21:45Z. --- Test-only change: `crates/victory-formats/src/xma/tables.rs` held 16 constant tables (Huffman pairs, code lengths, run/level tables) with no tests. ## What the tests pin - Every (symbol, code length) table — `SCALE`, `SCALE_RL`, `COEF1`, `VEC2`, `VEC1`, plus `COEF0_SYMS`/`COEF0_LENS` and `VEC4_SYMS`/`VEC4_LENS` zipped the way `xma.rs` consumes them — is a **complete prefix code**: walking the entries in code order with the same assignment `xma::Vlc::new` makes (`code += 1 << (32 - len)`) keeps every code in 32 bits, ends exactly at `1 << 32`, has unique symbols and lengths in 1..=32. - `CRITICAL_FREQ` is strictly increasing. - Each run/level table matches its Huffman table's length, and all level values are finite. ## Testing - [x] `cargo test -p victory-formats --lib xma::tables` — 3 pass - [x] `cargo test -p victory-formats -p victory-hle -p victory -p victory-gpu -p xtask` (host arm64) — all pass - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — clean - [x] `cargo xtask policy` — 404 files ok ## Checklist - [x] One change, one PR - [x] Branch `vibe/xma-tables-tests-1705ac` from `upstream/main`, pushed to my fork only - [x] No game/GDK files, no dumps/logs in the repo - [x] No AI attribution in the diff
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/611:upstream-pr/611'
git switch 'upstream-pr/611'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/611'
git switch 'upstream-pr/611'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/611'
git switch 'upstream-pr/611'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/611'
git switch 'main'
git merge --squash 'upstream-pr/611'
git switch 'main'
git merge --ff-only 'upstream-pr/611'
git switch 'main'
git merge 'upstream-pr/611'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!611
No description provided.