From 6f897e655a5f18b28b47542d76ac88d0aebcbc5d Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 3 Jan 2020 18:31:22 -0800 Subject: match changes in arch to have Resulty decode, instead of Option --- test/test.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test') 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 { let mut instr = Instruction::invalid(); match decode_one(&InstDecoder::default(), bytes.iter().map(|x| *x).take(16).collect::>(), &mut instr) { - Some(()) => Some(instr), - None => None + Ok(()) => Some(instr), + _ => None } } fn decode_as(decoder: &InstDecoder, bytes: &[u8]) -> Option { let mut instr = Instruction::invalid(); match decode_one(decoder, bytes.iter().map(|x| *x).take(16).collect::>(), &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); } } } -- cgit v1.1