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;
|
||||
|
||||
fn main() {
|
||||
test_sha224();
|
||||
test_sha256();
|
||||
println!("Running SHA tests...");
|
||||
test_sha();
|
||||
}
|
||||
|
||||
fn test_sha256() {
|
||||
println!(" Input: \"\"");
|
||||
println!(" Expected: 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
|
||||
println!(" Result Hash: 0x{}", sha::sha256("".to_string()));
|
||||
|
||||
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())
|
||||
fn test_sha() {
|
||||
assert_eq!(
|
||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
sha::sha256("".to_string()),
|
||||
"Testing hash for \"\""
|
||||
);
|
||||
|
||||
println!("_____________________________");
|
||||
}
|
||||
|
||||
fn test_sha224() {
|
||||
println!(" Input: \"\"");
|
||||
println!(" Expected: 0xd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f");
|
||||
println!(" Result Hash: 0x{}", sha::sha224("".to_string()));
|
||||
|
||||
println!("_____________________________");
|
||||
|
||||
println!(" Input: \"abc\"");
|
||||
println!(" Expected: 0x23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7");
|
||||
println!(" Result Hash: 0x{}", sha::sha224("abc".to_string()));
|
||||
|
||||
println!("_____________________________");
|
||||
|
||||
println!(" Input: \"The quick brown fox jumps over the lazy dog\"");
|
||||
println!(" Expected: 0x730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525");
|
||||
println!(
|
||||
" Result Hash: 0x{}",
|
||||
sha::sha224("The quick brown fox jumps over the lazy dog".to_string())
|
||||
assert_eq!(
|
||||
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
|
||||
sha::sha256("abc".to_string()),
|
||||
"Testing hash for \"abc\""
|
||||
);
|
||||
assert_eq!(
|
||||
"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592",
|
||||
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\""
|
||||
);
|
||||
assert_eq!(
|
||||
"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
|
||||
sha::sha224("".to_string()),
|
||||
"Testing hash for \"\""
|
||||
);
|
||||
assert_eq!(
|
||||
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7",
|
||||
sha::sha224("abc".to_string()),
|
||||
"Testing hash for \"abc\""
|
||||
);
|
||||
assert_eq!(
|
||||
"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