]> code.octet-stream.net Git - hashgood/commitdiff
Fix clippy lints in tests
authorThomas Karpiniec <tom.karpiniec@outlook.com>
Wed, 15 Jun 2022 12:25:17 +0000 (22:25 +1000)
committerThomas Karpiniec <tom.karpiniec@outlook.com>
Wed, 15 Jun 2022 12:25:17 +0000 (22:25 +1000)
src/calculate.rs
src/verify.rs

index 59395d3c6b5544969c41bab22d67efdeb0fb6b42..efc39860aa4a3fb3e9eeec9ac0bbc83f2711cd2a 100644 (file)
@@ -125,22 +125,22 @@ mod tests {
     use super::*;
     use std::io::Cursor;
 
     use super::*;
     use std::io::Cursor;
 
-    const SMALL_DATA: [u8; 10] = ['A' as u8; 10];
+    static SMALL_DATA: [u8; 10] = [b'A'; 10];
     // python3 -c 'print ("A"*10, end="", flush=True)' | md5sum
     // python3 -c 'print ("A"*10, end="", flush=True)' | md5sum
-    const SMALL_DATA_MD5: &'static str = "16c52c6e8326c071da771e66dc6e9e57";
+    static SMALL_DATA_MD5: &str = "16c52c6e8326c071da771e66dc6e9e57";
     // python3 -c 'print ("A"*10, end="", flush=True)' | sha1sum
     // python3 -c 'print ("A"*10, end="", flush=True)' | sha1sum
-    const SMALL_DATA_SHA1: &'static str = "c71613a7386fd67995708464bf0223c0d78225c4";
+    static SMALL_DATA_SHA1: &str = "c71613a7386fd67995708464bf0223c0d78225c4";
     // python3 -c 'print ("A"*10, end="", flush=True)' | sha256sum
     // python3 -c 'print ("A"*10, end="", flush=True)' | sha256sum
-    const SMALL_DATA_SHA256: &'static str =
+    static SMALL_DATA_SHA256: &str =
         "1d65bf29403e4fb1767522a107c827b8884d16640cf0e3b18c4c1dd107e0d49d";
 
         "1d65bf29403e4fb1767522a107c827b8884d16640cf0e3b18c4c1dd107e0d49d";
 
-    const LARGE_DATA: [u8; 1_000_000] = ['B' as u8; 1_000_000];
+    static LARGE_DATA: [u8; 1_000_000] = [b'B'; 1_000_000];
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | md5sum
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | md5sum
-    const LARGE_DATA_MD5: &'static str = "9171f6d67a87ca649a702434a03458a1";
+    static LARGE_DATA_MD5: &str = "9171f6d67a87ca649a702434a03458a1";
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | sha1sum
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | sha1sum
-    const LARGE_DATA_SHA1: &'static str = "cfae4cebfd01884111bdede7cf983626bb249c94";
+    static LARGE_DATA_SHA1: &str = "cfae4cebfd01884111bdede7cf983626bb249c94";
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | sha256sum
     // python3 -c 'print ("B"*1000000, end="", flush=True)' | sha256sum
-    const LARGE_DATA_SHA256: &'static str =
+    static LARGE_DATA_SHA256: &str =
         "b9193853f7798e92e2f6b82eda336fa7d6fc0fa90fdefe665f372b0bad8cdf8c";
 
     fn verify_digest(alg: Algorithm, data: &'static [u8], hash: &str) {
         "b9193853f7798e92e2f6b82eda336fa7d6fc0fa90fdefe665f372b0bad8cdf8c";
 
     fn verify_digest(alg: Algorithm, data: &'static [u8], hash: &str) {
@@ -154,9 +154,9 @@ mod tests {
     /// of test data (single block).
     #[test]
     fn small_digests() {
     /// of test data (single block).
     #[test]
     fn small_digests() {
-        verify_digest(Algorithm::Md5, &SMALL_DATA, &SMALL_DATA_MD5);
-        verify_digest(Algorithm::Sha1, &SMALL_DATA, &SMALL_DATA_SHA1);
-        verify_digest(Algorithm::Sha256, &SMALL_DATA, &SMALL_DATA_SHA256);
+        verify_digest(Algorithm::Md5, &SMALL_DATA, SMALL_DATA_MD5);
+        verify_digest(Algorithm::Sha1, &SMALL_DATA, SMALL_DATA_SHA1);
+        verify_digest(Algorithm::Sha256, &SMALL_DATA, SMALL_DATA_SHA256);
     }
 
     /// Assert that digests for all algorithms are calculated correctly for a large piece
     }
 
     /// Assert that digests for all algorithms are calculated correctly for a large piece
@@ -165,8 +165,8 @@ mod tests {
     /// 1 MiB means that the final block will be slightly smaller than the others.
     #[test]
     fn large_digests() {
     /// 1 MiB means that the final block will be slightly smaller than the others.
     #[test]
     fn large_digests() {
-        verify_digest(Algorithm::Md5, &LARGE_DATA, &LARGE_DATA_MD5);
-        verify_digest(Algorithm::Sha1, &LARGE_DATA, &LARGE_DATA_SHA1);
-        verify_digest(Algorithm::Sha256, &LARGE_DATA, &LARGE_DATA_SHA256);
+        verify_digest(Algorithm::Md5, &LARGE_DATA, LARGE_DATA_MD5);
+        verify_digest(Algorithm::Sha1, &LARGE_DATA, LARGE_DATA_SHA1);
+        verify_digest(Algorithm::Sha256, &LARGE_DATA, LARGE_DATA_SHA256);
     }
 }
     }
 }
index c9ded29f9a083685d7ed5dd55fbf9eafa8f1ccff..0f2d1d88325de4e19b90da50479bd75b6fd81b52 100644 (file)
@@ -299,28 +299,28 @@ mod tests {
         let invalid5 = "1eb85fc97224598dad1852b5d 483bbcf0aa8608790dcc657a5a2a761ae9c8c6";
 
         assert!(matches!(
         let invalid5 = "1eb85fc97224598dad1852b5d 483bbcf0aa8608790dcc657a5a2a761ae9c8c6";
 
         assert!(matches!(
-            read_raw_candidate_from_file(valid_md5, &example_path),
+            read_raw_candidate_from_file(valid_md5, example_path),
             Some(CandidateHashes {
                 alg: Algorithm::Md5,
                 ..
             })
         ));
         assert!(matches!(
             Some(CandidateHashes {
                 alg: Algorithm::Md5,
                 ..
             })
         ));
         assert!(matches!(
-            read_raw_candidate_from_file(valid_sha1, &example_path),
+            read_raw_candidate_from_file(valid_sha1, example_path),
             Some(CandidateHashes {
                 alg: Algorithm::Sha1,
                 ..
             })
         ));
         assert!(matches!(
             Some(CandidateHashes {
                 alg: Algorithm::Sha1,
                 ..
             })
         ));
         assert!(matches!(
-            read_raw_candidate_from_file(&valid_sha1_2, &example_path),
+            read_raw_candidate_from_file(&valid_sha1_2, example_path),
             Some(CandidateHashes {
                 alg: Algorithm::Sha1,
                 ..
             })
         ));
         assert!(matches!(
             Some(CandidateHashes {
                 alg: Algorithm::Sha1,
                 ..
             })
         ));
         assert!(matches!(
-            read_raw_candidate_from_file(valid_sha256, &example_path),
+            read_raw_candidate_from_file(valid_sha256, example_path),
             Some(CandidateHashes {
                 alg: Algorithm::Sha256,
                 ..
             Some(CandidateHashes {
                 alg: Algorithm::Sha256,
                 ..
@@ -328,7 +328,7 @@ mod tests {
         ));
 
         for i in &[invalid1, invalid2, invalid3, invalid4, invalid5] {
         ));
 
         for i in &[invalid1, invalid2, invalid3, invalid4, invalid5] {
-            assert!(read_raw_candidate_from_file(*i, &example_path).is_none());
+            assert!(read_raw_candidate_from_file(*i, example_path).is_none());
         }
     }
 
         }
     }
 
@@ -338,9 +338,9 @@ mod tests {
         75eb7420a9f5a260b04a3e8ad51e50f2838a17fc  lel.txt
 
         fe6c26d485a3573a1cb0ad0682f5105325a1905f  shasums";
         75eb7420a9f5a260b04a3e8ad51e50f2838a17fc  lel.txt
 
         fe6c26d485a3573a1cb0ad0682f5105325a1905f  shasums";
-        let lines = shasums.lines().map(|l| std::io::Result::Ok(l));
+        let lines = shasums.lines().map(std::io::Result::Ok);
         let path = Path::new("SHASUMS");
         let path = Path::new("SHASUMS");
-        let candidates = read_coreutils_digests_from_file(lines, &path);
+        let candidates = read_coreutils_digests_from_file(lines, path);
 
         assert_eq!(
             candidates,
 
         assert_eq!(
             candidates,
@@ -372,7 +372,7 @@ mod tests {
         let extra_space = "4b91f7a387a6edd4a7c0afb2897f1ca968c9695b   cp";
 
         for digest in [no_format, invalid_format, extra_space] {
         let extra_space = "4b91f7a387a6edd4a7c0afb2897f1ca968c9695b   cp";
 
         for digest in [no_format, invalid_format, extra_space] {
-            let lines = digest.lines().map(|l| std::io::Result::Ok(l));
+            let lines = digest.lines().map(std::io::Result::Ok);
             assert!(
                 read_coreutils_digests_from_file(lines, Path::new("SHASUMS")).is_none(),
                 "Should be invalid digest: {:?}",
             assert!(
                 read_coreutils_digests_from_file(lines, Path::new("SHASUMS")).is_none(),
                 "Should be invalid digest: {:?}",