Skip to content

test(huf): targeted regression tests for HUF 4-stream burst gate boundary states in decode_literals #202

Description

@coderabbitai

Summary

Add targeted unit tests for the HUF 4-stream burst gate boundaries in literals_section_decoder.rs::decode_literals (lines 148–292).

Motivation

The existing decode_corpus / encode_corpus / level_1_fast c_stream integration tests cover the burst gate states organically, so a regression would surface before merge. However, explicit unit tests would significantly speed up triage on any future gate tweak.

This work was identified as out of scope for #201 (requires ~200 LOC of synthetic HUF bitstream scaffolding) and is tracked here as a follow-up.

Edge cases to cover

  1. bits_consumed == max_num_bits — exact lower boundary of the burst gate; the burst is entered for the first time (gate condition is met with zero slack).
  2. bits_consumed + burst_bits == 64 — exact upper boundary; the burst consumes all remaining bits in the 64-bit window without overflow.
  3. SIMD-fallback → refill → burst re-entry transition — the outer loop falls back to the SIMD 4-symbol path, a BitReaderReversed refill occurs, and the next iteration correctly re-enters the burst path once the gate holds again.

Acceptance criteria

  • Synthetic HUF bitstream scaffolding (~200 LOC) that can construct streams hitting the three states above deterministically.
  • Unit tests asserting correct symbol output and correct bits_consumed / bit_container state after each transition.
  • Tests are gated under #[cfg(test)] and run cleanly under cargo nextest.
  • No ratio regression; clippy clean.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions