Summary
The Java SDK (open-feature/java-sdk-contrib#1740) added a statistical distribution test that iterates over the full 32-bit hash space (step 127) and verifies that bucket hits are near-perfectly uniform (max−min delta < 3 across 16 equal-weight buckets).
We should add the equivalent test for Rust to:
- Pin the
distribute_by_hash core logic against regression
- Verify the integer multiply-shift formula produces a uniform distribution
- Add edge-case coverage for boundary hash values (0, 1, u32::MAX, etc.)
Changes
- Extract a
#[cfg(test)]-visible distribute_by_hash(hash: u32, ...) helper from fractional()
- Add
test_fractional_distribution_uniformity iterating over 0..=u32::MAX step 127
- Add
test_boundary_hashes_do_not_panic covering 0, 1, u32::MAX, u32::MAX-1, u32::MAX/2
Mirrors Java: open-feature/java-sdk-contrib#1740
Summary
The Java SDK (open-feature/java-sdk-contrib#1740) added a statistical distribution test that iterates over the full 32-bit hash space (step 127) and verifies that bucket hits are near-perfectly uniform (max−min delta < 3 across 16 equal-weight buckets).
We should add the equivalent test for Rust to:
distribute_by_hashcore logic against regressionChanges
#[cfg(test)]-visibledistribute_by_hash(hash: u32, ...)helper fromfractional()test_fractional_distribution_uniformityiterating over 0..=u32::MAX step 127test_boundary_hashes_do_not_paniccovering 0, 1, u32::MAX, u32::MAX-1, u32::MAX/2Mirrors Java: open-feature/java-sdk-contrib#1740