fix tests

This commit is contained in:
Dmitry Belyaev 2022-08-27 23:42:00 +03:00
parent 2d5b27d423
commit f4274d703d
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -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<u8> = 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<bool> = 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<usize> = 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(" ", "");