// originally from https://gitlab.redox-os.org/redox-os/seahash/issues/5
letc1:&[u8]=b"This hashing algorithm was extracted from the Rustc compiler.";
letc2:&[u8]=b" This is the same hashing algoirthm used for some internal operations in FireFox.";
letc3:&[u8]=b" The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one byte at a time.";
letmuth1=H::default();
h1.write(c1);
h1.write(c2);
h1.write(c3);
lethash1=h1.finish();
letmutc4=Vec::<u8>::new();
c4.extend_from_slice(c1);
c4.extend_from_slice(c2);
c4.extend_from_slice(c3);
letmuth2=H::default();
h2.write(&c4);
lethash2=h2.finish();
letreference=seahash::reference::hash(&c4);
letbuffer=seahash::hash(&c4);
println!("hash1: {:016x}",hash1);
println!("hash2: {:016x}",hash2);
println!("ref : {:016x}",reference);
println!("buf : {:016x}",buffer);
assert_eq!(hash1,hash2);
assert_eq!(hash1,reference);
assert_eq!(hash1,buffer);
}
#[test]
fntest_different_chunk_sizes(){
letv={
letc1:&[u8]=b"This hashing algorithm was extracted from the Rustc compiler.";
letc2:&[u8]=b" This is the same hashing algoirthm used for some internal operations in FireFox.";
letc3:&[u8]=b" The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one byte at a time.";
[c1,c2,c3].concat()
};
letmuth1=H::default();
h1.write(&v);
leth1=h1.finish();
forchunk_lenin1..v.len(){
letmuth2=H::default();
forwinv.chunks(chunk_len){
h2.write(w);
}
leth2=h2.finish();
assert_eq!(h1,h2,"failed with chunk_len={}",chunk_len);