From f4274d703d579039e9e50ee00289cc696ded0cf1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 27 Aug 2022 23:42:00 +0300 Subject: [PATCH] fix tests --- lib/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 70c81b7..8322161 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -50,7 +50,7 @@ impl BytesPattern { impl FromStr for BytesPattern { type Err = &'static str; fn from_str(str_val: &str) -> Result { - if str_val.is_empty() { + if str_val.is_empty() { return Err("string is empty"); } @@ -132,7 +132,7 @@ mod tests { #[test] fn bytes_from_pattern() { let src_pattern = "E8 4D F8 FF 83 C4 85 C0 5F 75 32 8B 54 24 48 50 50"; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); let bytes: Vec = vec![ 0xE8, 0x4D, 0xF8, 0xFF, 0x83, 0xC4, 0x85, 0xC0, 0x5F, 0x75, 0x32, 0x8B, 0x54, 0x24, 0x48, 0x50, 0x50, @@ -142,7 +142,7 @@ mod tests { #[test] fn mask_from_pattern() { let src_pattern = "E8 ?? ?? FF ?? C4 ?? ?? 5F 75 32 ?? 54 24 48 50 50"; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); let mask: Vec = vec![ false, true, true, false, true, false, true, true, false, false, false, true, false, false, false, false, false, @@ -155,7 +155,7 @@ mod tests { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, ]; let src_pattern = "EE FF 00 11 22"; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); let offset = src_data.as_slice().find_pattern_first(&pattern); assert_eq!(offset, 4); } @@ -166,7 +166,7 @@ mod tests { 0xDD, 0xAA, 0xBB, 0xCC, ]; let src_pattern = "AA BB CC AA BB DD"; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); let offset = src_data.as_slice().find_pattern_first(&pattern); assert_eq!(offset, 9); } @@ -174,7 +174,7 @@ mod tests { fn prefix_function() { let src_pattern = "AA BB BB AA AA BB BB AA BB"; let expected_pi: Vec = vec![0, 0, 0, 1, 1, 2, 3, 4, 2]; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); assert_eq!(pattern.pi, expected_pi); } #[test] @@ -187,7 +187,7 @@ mod tests { ]; let src_pattern = "EE FF 00 11 22"; let replacement = "99 88 77 66 55"; - let pattern = BytesPattern::from(src_pattern); + let pattern: BytesPattern = src_pattern.parse().unwrap(); let offset = src_data.as_slice().find_pattern_first(&pattern); let replacement = replacement.replace(" ", "");