This is an automated email from the ASF dual-hosted git repository.

tisonkun pushed a commit to branch codex/analyze-crate-tests
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git

commit abda940a81e9023348b8a4ff82a62528adf61667
Author: tison <[email protected]>
AuthorDate: Tue Jul 28 14:40:59 2026 +0800

    test(hash): cover streaming write boundaries
---
 datasketches/src/hash/murmurhash.rs | 18 ++++++++++++++++++
 datasketches/src/hash/xxhash.rs     | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/datasketches/src/hash/murmurhash.rs 
b/datasketches/src/hash/murmurhash.rs
index a99f5eb..03345f2 100644
--- a/datasketches/src/hash/murmurhash.rs
+++ b/datasketches/src/hash/murmurhash.rs
@@ -186,6 +186,24 @@ mod tests {
         hasher.finish128()
     }
 
+    #[test]
+    fn streaming_writes_match_single_write() {
+        let input: Vec<u8> = (0..=96).collect();
+        for len in 0..=input.len() {
+            let expected = murmurhash3_x64_128(&input[..len], 42);
+            for split in 0..=len {
+                let mut hasher = MurmurHash3X64128::with_seed(42);
+                hasher.write(&input[..split]);
+                hasher.write(&input[split..len]);
+                assert_eq!(
+                    hasher.finish128(),
+                    expected,
+                    "hash changed for input length {len} split at {split}"
+                );
+            }
+        }
+    }
+
     #[test]
     fn test_remainder() {
         // remainder > 8
diff --git a/datasketches/src/hash/xxhash.rs b/datasketches/src/hash/xxhash.rs
index 6232c04..25852ea 100644
--- a/datasketches/src/hash/xxhash.rs
+++ b/datasketches/src/hash/xxhash.rs
@@ -216,6 +216,24 @@ mod tests {
         hasher.finish64()
     }
 
+    #[test]
+    fn streaming_writes_match_single_write() {
+        let input: Vec<u8> = (0..=96).collect();
+        for len in 0..=input.len() {
+            let expected = xxhash64(&input[..len], PRIME32);
+            for split in 0..=len {
+                let mut hasher = XxHash64::with_seed(PRIME32);
+                hasher.write(&input[..split]);
+                hasher.write(&input[split..len]);
+                assert_eq!(
+                    hasher.finish64(),
+                    expected,
+                    "hash changed for input length {len} split at {split}"
+                );
+            }
+        }
+    }
+
     #[test]
     fn test_vectors_seed_zero() {
         let buf = fill_test_buffer(101);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to