Skip to content

Instantly share code, notes, and snippets.

@xavierd
Created July 2, 2019 00:25
Show Gist options
  • Save xavierd/76009599e219a49c0c18fbc44790413d to your computer and use it in GitHub Desktop.
Save xavierd/76009599e219a49c0c18fbc44790413d to your computer and use it in GitHub Desktop.
#[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