Summary
Add a dedicated unit test for HcMatchGenerator cross-slice boundary position seeding, analogous to dfast_inserts_tail_positions_for_next_block_matching() in zstd/src/encoding/match_generator.rs.
Background
In PR #48, a routing check was added to verify that CompressionLevel::Better switches to the MatcherBackend::HashChain backend with lazy_depth == 2. However, there is no dedicated unit test that locks down the HcMatchGenerator's slice-boundary seeding logic (backfill_boundary_positions).
The existing 8 MiB window roundtrip test exercises cross-slice behavior end-to-end, but a targeted unit test analogous to dfast_inserts_tail_positions_for_next_block_matching() would more precisely catch boundary-anchor losses in HcMatchGenerator.
Proposed Test
A new test hashchain_inserts_tail_positions_for_next_block_matching() in zstd/src/encoding/match_generator.rs should:
- Create an
HcMatchGenerator (or use a MatchGeneratorDriver reset to CompressionLevel::Better).
- Feed a first slice with a known repeating pattern (e.g., similar to the Dfast test).
- Call
start_matching / skip_matching to process the first slice.
- Feed a second slice with content that overlaps the boundary of the first slice.
- Assert that a cross-block match is produced immediately at the slice boundary (no leading literals), confirming that
backfill_boundary_positions correctly seeded the tail of the previous slice.
References
Summary
Add a dedicated unit test for
HcMatchGeneratorcross-slice boundary position seeding, analogous todfast_inserts_tail_positions_for_next_block_matching()inzstd/src/encoding/match_generator.rs.Background
In PR #48, a routing check was added to verify that
CompressionLevel::Betterswitches to theMatcherBackend::HashChainbackend withlazy_depth == 2. However, there is no dedicated unit test that locks down theHcMatchGenerator's slice-boundary seeding logic (backfill_boundary_positions).The existing 8 MiB window roundtrip test exercises cross-slice behavior end-to-end, but a targeted unit test analogous to
dfast_inserts_tail_positions_for_next_block_matching()would more precisely catch boundary-anchor losses inHcMatchGenerator.Proposed Test
A new test
hashchain_inserts_tail_positions_for_next_block_matching()inzstd/src/encoding/match_generator.rsshould:HcMatchGenerator(or use aMatchGeneratorDriverreset toCompressionLevel::Better).start_matching/skip_matchingto process the first slice.backfill_boundary_positionscorrectly seeded the tail of the previous slice.References