-
Notifications
You must be signed in to change notification settings - Fork 0
add unit test for HcMatchGenerator cross-slice boundary position seeding #49
Description
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 aMatchGeneratorDriverreset toCompressionLevel::Better). - Feed a first slice with a known repeating pattern (e.g., similar to the Dfast test).
- Call
start_matching/skip_matchingto 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_positionscorrectly seeded the tail of the previous slice.
References
- PR feat(encoding): add Better compression level (zstd level 7, lazy2 strategy) #48 — feat(encoding): add Better compression level (lazy2 strategy)
- Comment: feat(encoding): add Better compression level (zstd level 7, lazy2 strategy) #48 (comment)
- Requested by: @polaz