Skip to content

Commit

Permalink
add tests for hashers threadpool
Browse files Browse the repository at this point in the history
  • Loading branch information
rakurame96 committed Dec 26, 2024
1 parent 5120bb8 commit a5ac83c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/hashers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,56 @@ mod tests {

assert_eq!(hash, hash_2);
}

#[test]
fn test_sha_256_threadpool_compare_fail() {
let path = Path::new("tests/test.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let hash = <CASSHA as CASHasher>::hash_256_threadpool(file_bytes);

let path_2 = Path::new("tests/test2.docx");
let file_bytes_2: Vec<u8> = std::fs::read(path_2).unwrap();
let hash_2 = <CASSHA as CASHasher>::hash_256_threadpool(file_bytes_2);

assert_ne!(hash, hash_2);
}

#[test]
fn test_sha_256_threadpool_success() {
let path = Path::new("tests/test.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let hash = <CASSHA as CASHasher>::hash_256_threadpool(file_bytes);

let path_2 = Path::new("tests/test.docx");
let file_bytes_2: Vec<u8> = std::fs::read(path).unwrap();
let hash_2 = <CASSHA as CASHasher>::hash_256_threadpool(file_bytes_2);

assert_eq!(hash, hash_2);
}

#[test]
fn test_sha_512_threadpool_compare_fail() {
let path = Path::new("tests/test.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let hash = <CASSHA as CASHasher>::hash_512_threadpool(file_bytes);

let path_2 = Path::new("tests/test2.docx");
let file_bytes_2: Vec<u8> = std::fs::read(path_2).unwrap();
let hash_2 = <CASSHA as CASHasher>::hash_512_threadpool(file_bytes_2);

assert_ne!(hash, hash_2);
}

#[test]
fn test_sha_512_threadpool_success() {
let path = Path::new("tests/test.docx");
let file_bytes: Vec<u8> = std::fs::read(path).unwrap();
let hash = <CASSHA as CASHasher>::hash_512_threadpool(file_bytes);

let path_2 = Path::new("tests/test.docx");
let file_bytes_2: Vec<u8> = std::fs::read(path).unwrap();
let hash_2 = <CASSHA as CASHasher>::hash_512_threadpool(file_bytes_2);

assert_eq!(hash, hash_2);
}
}

0 comments on commit a5ac83c

Please sign in to comment.