Skip to content

Commit

Permalink
Extend the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Apr 28, 2024
1 parent 0c0dbe8 commit c999060
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ fn rotate(a: &mut u32, b: &mut u32, c: &mut u32, d: &mut u32, mut f: u32, g: u32
mod tests {
use std::io::prelude::Write;

use super::Context;

#[test]
fn compute() {
let inputs = [
Expand All @@ -325,7 +327,13 @@ mod tests {
"57edf4a22be3c955ac49da2e2107b67a",
];
for (input, &output) in inputs.iter().zip(outputs.iter()) {
assert_eq!(format!("{:x}", super::compute(input)), output);
let digest = super::compute(input);
assert_eq!(format!("{digest:x}"), output);

let mut context = Context::new();
context.consume(input);
let digest = context.finalize();
assert_eq!(format!("{digest:x}"), output);
}
}

Expand All @@ -340,7 +348,7 @@ mod tests {
#[test]
fn write_29() {
let data = vec![0; 8 * 1024 * 1024];
let mut context = super::Context::new();
let mut context = Context::new();
for _ in 0..64 {
context.write(&data).unwrap();
}
Expand All @@ -353,7 +361,7 @@ mod tests {
#[test]
fn write_32() {
let data = vec![0; std::u32::MAX as usize + 1];
let mut context = super::Context::new();
let mut context = Context::new();
context.write(&data).unwrap();
assert_eq!(
format!("{:x}", context.finalize()),
Expand Down

0 comments on commit c999060

Please sign in to comment.