Added unit test to test that new cloning feature works as intended
This commit is contained in:
parent
8fae1115a4
commit
5991f425fa
|
|
@ -313,6 +313,20 @@ mod test {
|
||||||
assert_eq!(hex::encode(hasher.finish()), expected);
|
assert_eq!(hex::encode(hasher.finish()), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cloning_allows_incremental_hashing() {
|
||||||
|
let expected = "a9993e364706816aba3e25717850c26c9cd0d89d";
|
||||||
|
|
||||||
|
let mut hasher = Sha1::new();
|
||||||
|
hasher.update(b"a");
|
||||||
|
|
||||||
|
let mut incr_hasher = hasher.clone();
|
||||||
|
incr_hasher.update(b"bc");
|
||||||
|
|
||||||
|
assert_eq!(hex::encode(incr_hasher.finish()), expected);
|
||||||
|
assert_ne!(hex::encode(hasher.finish()), expected);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_224() {
|
fn standalone_224() {
|
||||||
let data = b"abc";
|
let data = b"abc";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue