Added proper asserts to test functions
This commit is contained in:
parent
7e6dc13781
commit
b644455842
75
src/main.rs
75
src/main.rs
@ -1,52 +1,39 @@
|
|||||||
mod sha;
|
mod sha;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test_sha224();
|
println!("Running SHA tests...");
|
||||||
test_sha256();
|
test_sha();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_sha256() {
|
fn test_sha() {
|
||||||
println!(" Input: \"\"");
|
assert_eq!(
|
||||||
println!(" Expected: 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
|
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||||
println!(" Result Hash: 0x{}", sha::sha256("".to_string()));
|
sha::sha256("".to_string()),
|
||||||
|
"Testing hash for \"\""
|
||||||
println!("_____________________________");
|
|
||||||
|
|
||||||
println!(" Input: \"abc\"");
|
|
||||||
println!(" Expected: 0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
|
|
||||||
println!(" Result Hash: 0x{}", sha::sha256("abc".to_string()));
|
|
||||||
|
|
||||||
println!("_____________________________");
|
|
||||||
|
|
||||||
println!(" Input: \"The quick brown fox jumps over the lazy dog\"");
|
|
||||||
println!(" Expected: 0xd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592");
|
|
||||||
println!(
|
|
||||||
" Result Hash: 0x{}",
|
|
||||||
sha::sha256("The quick brown fox jumps over the lazy dog".to_string())
|
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
println!("_____________________________");
|
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
|
||||||
}
|
sha::sha256("abc".to_string()),
|
||||||
|
"Testing hash for \"abc\""
|
||||||
fn test_sha224() {
|
);
|
||||||
println!(" Input: \"\"");
|
assert_eq!(
|
||||||
println!(" Expected: 0xd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f");
|
"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592",
|
||||||
println!(" Result Hash: 0x{}", sha::sha224("".to_string()));
|
sha::sha256("The quick brown fox jumps over the lazy dog".to_string()),
|
||||||
|
"Testing hash for \"The quick brown fox jumps over the lazy dog\""
|
||||||
println!("_____________________________");
|
);
|
||||||
|
assert_eq!(
|
||||||
println!(" Input: \"abc\"");
|
"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
|
||||||
println!(" Expected: 0x23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7");
|
sha::sha224("".to_string()),
|
||||||
println!(" Result Hash: 0x{}", sha::sha224("abc".to_string()));
|
"Testing hash for \"\""
|
||||||
|
);
|
||||||
println!("_____________________________");
|
assert_eq!(
|
||||||
|
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7",
|
||||||
println!(" Input: \"The quick brown fox jumps over the lazy dog\"");
|
sha::sha224("abc".to_string()),
|
||||||
println!(" Expected: 0x730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525");
|
"Testing hash for \"abc\""
|
||||||
println!(
|
);
|
||||||
" Result Hash: 0x{}",
|
assert_eq!(
|
||||||
sha::sha224("The quick brown fox jumps over the lazy dog".to_string())
|
"730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525",
|
||||||
|
sha::sha224("The quick brown fox jumps over the lazy dog".to_string()),
|
||||||
|
"Testing hash for \"The quick brown fox jumps over the lazy dog\""
|
||||||
);
|
);
|
||||||
|
|
||||||
println!("_____________________________");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user