Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 2.74 KB

File metadata and controls

37 lines (25 loc) · 2.74 KB

Testing Strategy

Chronicle Software

Regression Coverage

  • LongHashFunctionTest.test is the canonical harness for verifying that an algorithm produces identical values across the entire API surface (primitives, arrays, buffers, Access-backed inputs, and direct memory). All algorithm-specific tests delegate to this helper when checking new vectors (LongHashFunctionTest.java:23-189).

  • Tuple variants reuse the same assertions through LongTupleHashFunctionTest (invoked transitively), ensuring the 128-bit paths remain aligned with their 64-bit projections.

Reference Vectors

  • CityHash and FarmHash tests (City64_1_1_Test, FarmHashTest, OriginalFarmHashTest) replay the official C++ outputs for inputs up to 1024 bytes with deterministic seeds. The source programs used to generate those vectors are embedded in each test for reproducibility.

  • XXH64 (XxHashTest), XXH3 (XXH3Test), and XXH128 (XXH128Test) load tables generated by the upstream xxHash project, covering lengths up to two full XXH3 blocks.

  • MetroHash (MetroHashTest) and wyHash (WyHashTest) follow the same pattern with public reference implementations, ensuring the adapted Java code remains bit-for-bit compatible.

  • Collision and edge case tests (XxHashCollisionTest, OriginalFarmHashTest) target previously reported defects and must continue to pass to guard against regressions.

Endianness Validation

  • Every algorithm test is executed under both native and non-native byte orders by virtue of the LongHashFunctionTest helper, which rewrites ByteBuffer order and exercises the Access.byteOrder adaptation code paths.

  • Dedicated tests such as LongHashFunctionTest.testNegativePrimitives confirm that signed primitive hashes match the equivalent unsigned byte sequences, catching regressions in Primitives.nativeToLittleEndian.

Adding or Modifying Algorithms

  1. Generate authoritative reference hashes using the upstream implementation (the existing tests include example C or C++ snippets).

  2. Create or extend a parameterised JUnit test that iterates over message lengths (the standard pattern covers lengths [0, N] with N at least 1024).

  3. Feed the new vectors through LongHashFunctionTest.test (or the tuple equivalent) to validate all API entry points.

  4. Augment LongHashFunctionTest if the algorithm exposes new surface area (for example, additional primitive types or new Access strategies).

Build and Verification

  • Run mvn -q verify from the repository root before publishing changes; the goal invokes unit tests under the appropriate JVM profiles and ensures multi-version compatibility.

  • Include new regression cases alongside the code change so future automated runs catch behavioural drift without manual intervention.