diff options
author | iximeow <me@iximeow.net> | 2020-01-03 18:31:22 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2020-01-12 16:10:14 -0800 |
commit | 6f897e655a5f18b28b47542d76ac88d0aebcbc5d (patch) | |
tree | 4c464e9801e4976360b4d86fa3bfff3f7794b0e4 /test | |
parent | e5c38434423e3f0e936c6b9718063866b3e3347c (diff) |
match changes in arch to have Resulty decode, instead of Option
Diffstat (limited to 'test')
-rw-r--r-- | test/test.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/test.rs b/test/test.rs index 662d358..96f77be 100644 --- a/test/test.rs +++ b/test/test.rs @@ -9,16 +9,16 @@ use yaxpeax_x86::{Instruction, InstDecoder, decode_one}; fn decode(bytes: &[u8]) -> Option<Instruction> { let mut instr = Instruction::invalid(); match decode_one(&InstDecoder::default(), bytes.iter().map(|x| *x).take(16).collect::<Vec<u8>>(), &mut instr) { - Some(()) => Some(instr), - None => None + Ok(()) => Some(instr), + _ => None } } fn decode_as(decoder: &InstDecoder, bytes: &[u8]) -> Option<Instruction> { let mut instr = Instruction::invalid(); match decode_one(decoder, bytes.iter().map(|x| *x).take(16).collect::<Vec<u8>>(), &mut instr) { - Some(()) => Some(instr), - None => None + Ok(()) => Some(instr), + _ => None } } @@ -27,7 +27,7 @@ fn test_invalid(data: &[u8]) { } fn test_invalid_under(decoder: &InstDecoder, data: &[u8]) { - if let Some(inst) = decoder.decode(data.into_iter().cloned()) { + if let Ok(inst) = decoder.decode(data.into_iter().cloned()) { assert_eq!(inst.opcode, yaxpeax_x86::Opcode::Invalid, "decoded {:?} from {:02x?} under decoder {}", inst.opcode, data, decoder); } else { // this is fine @@ -44,7 +44,7 @@ fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str write!(hex, "{:02x}", b).unwrap(); } match decoder.decode(data.into_iter().map(|x| *x)) { - Some(instr) => { + Ok(instr) => { let text = format!("{}", instr); assert!( text == expected, @@ -56,8 +56,8 @@ fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str expected ); }, - None => { - assert!(false, "decode error for {} under decoder {}:\n expected: {}\n", hex, decoder, expected); + Err(e) => { + assert!(false, "decode error ({}) for {} under decoder {}:\n expected: {}\n", e, hex, decoder, expected); } } } |