From a5ac83c40d0ef475d97df47817a3c2bda731ffdd Mon Sep 17 00:00:00 2001 From: Rakuram Date: Thu, 26 Dec 2024 14:51:02 +0530 Subject: [PATCH] add tests for hashers threadpool --- tests/hashers.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/hashers.rs b/tests/hashers.rs index 9df917a..5e6c0e4 100644 --- a/tests/hashers.rs +++ b/tests/hashers.rs @@ -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 = std::fs::read(path).unwrap(); + let hash = ::hash_256_threadpool(file_bytes); + + let path_2 = Path::new("tests/test2.docx"); + let file_bytes_2: Vec = std::fs::read(path_2).unwrap(); + let hash_2 = ::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 = std::fs::read(path).unwrap(); + let hash = ::hash_256_threadpool(file_bytes); + + let path_2 = Path::new("tests/test.docx"); + let file_bytes_2: Vec = std::fs::read(path).unwrap(); + let hash_2 = ::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 = std::fs::read(path).unwrap(); + let hash = ::hash_512_threadpool(file_bytes); + + let path_2 = Path::new("tests/test2.docx"); + let file_bytes_2: Vec = std::fs::read(path_2).unwrap(); + let hash_2 = ::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 = std::fs::read(path).unwrap(); + let hash = ::hash_512_threadpool(file_bytes); + + let path_2 = Path::new("tests/test.docx"); + let file_bytes_2: Vec = std::fs::read(path).unwrap(); + let hash_2 = ::hash_512_threadpool(file_bytes_2); + + assert_eq!(hash, hash_2); + } } \ No newline at end of file