Created
July 2, 2019 00:25
-
-
Save xavierd/76009599e219a49c0c18fbc44790413d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use twox_hash::XxHash32; | |
use std::hash::Hasher; | |
fn xxhash32<T: AsRef<[u8]>>(buf: T) -> u64 { | |
let mut xx = XxHash32::default(); | |
xx.write(buf.as_ref()); | |
xx.finish() | |
} | |
#[test] | |
fn test_repro() { | |
let v1 = vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; | |
let h1 = xxhash32(&v1); | |
let v2 = vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; | |
let v2_unaligned = v2.split_at(2).1; | |
let h2 = xxhash32(&v2_unaligned); | |
assert_eq!(h1, h2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment