Hasher::write(): add basic test
This commit is contained in:
parent
b9f95b4ce4
commit
3cbc518249
|
|
@ -120,6 +120,12 @@ mod tests {
|
|||
assert!(calced == hashtest.expected_output);
|
||||
}
|
||||
|
||||
pub fn hash_writer(t: super::HashType, data: &[u8]) -> Vec<u8> {
|
||||
let mut h = super::Hasher::new(t);
|
||||
h.write(data);
|
||||
h.finalize()
|
||||
}
|
||||
|
||||
// Test vectors from http://www.nsrl.nist.gov/testdata/
|
||||
#[test]
|
||||
fn test_md5() {
|
||||
|
|
@ -175,4 +181,11 @@ mod tests {
|
|||
hash_test(super::RIPEMD160, test);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_writer() {
|
||||
let tv = "rust-openssl".as_bytes();
|
||||
let ht = super::RIPEMD160;
|
||||
assert!(hash_writer(ht, tv) == super::hash(ht, tv));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue