Skip to content

add unit test for HcMatchGenerator cross-slice boundary position seeding #49

@coderabbitai

Description

@coderabbitai

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:

  1. Create an HcMatchGenerator (or use a MatchGeneratorDriver reset to CompressionLevel::Better).
  2. Feed a first slice with a known repeating pattern (e.g., similar to the Dfast test).
  3. Call start_matching / skip_matching to process the first slice.
  4. Feed a second slice with content that overlaps the boundary of the first slice.
  5. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions