Skip to content

test(fractional): add statistical distribution test mirroring Java PR #1740 #29

@aepfli

Description

@aepfli

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

Metadata

Metadata

Assignees

No one assigned

    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