diff options
| author | Cody P Schafer <[email protected]> | 2014-11-07 16:56:00 -0500 |
|---|---|---|
| committer | Cody P Schafer <[email protected]> | 2014-11-07 16:58:30 -0500 |
| commit | 3cbc5182496297abab0918430a9d5e72295c0b24 (patch) | |
| tree | 1d7083db3cf61f1261dc867c13ffdf6cc5c5b59c /src/crypto/hash.rs | |
| parent | crypto/hash: impl Writer for Hasher to allow use of Reader-Writer convenience... (diff) | |
| download | rust-openssl-3cbc5182496297abab0918430a9d5e72295c0b24.tar.xz rust-openssl-3cbc5182496297abab0918430a9d5e72295c0b24.zip | |
Hasher::write(): add basic test
Diffstat (limited to 'src/crypto/hash.rs')
| -rw-r--r-- | src/crypto/hash.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs index 60517adf..b00dfba8 100644 --- a/src/crypto/hash.rs +++ b/src/crypto/hash.rs @@ -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)); + } } |