Chronicle Software
-
LongHashFunctionTest.testis 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.
-
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.
-
Every algorithm test is executed under both native and non-native byte orders by virtue of the
LongHashFunctionTesthelper, which rewritesByteBufferorder and exercises theAccess.byteOrderadaptation code paths. -
Dedicated tests such as
LongHashFunctionTest.testNegativePrimitivesconfirm that signed primitive hashes match the equivalent unsigned byte sequences, catching regressions inPrimitives.nativeToLittleEndian.
-
Generate authoritative reference hashes using the upstream implementation (the existing tests include example C or C++ snippets).
-
Create or extend a parameterised JUnit test that iterates over message lengths (the standard pattern covers lengths
[0, N]withNat least 1024). -
Feed the new vectors through
LongHashFunctionTest.test(or the tuple equivalent) to validate all API entry points. -
Augment
LongHashFunctionTestif the algorithm exposes new surface area (for example, additional primitive types or newAccessstrategies).
-
Run
mvn -q verifyfrom 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.