From c903c7ece85d22f3ee310ebaaa73241402e0be70 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 12 Oct 2020 00:45:51 -0700 Subject: do not panic on invalid instructions --- tests/test.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test.rs') diff --git a/tests/test.rs b/tests/test.rs index 729aed1..683818e 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -25,6 +25,15 @@ use yaxpeax_arch::Decoder; // 1000 2806 9811 5002 2000 4200 50a5 ff58 #[test] +fn test_invalid_instruction() { + let decoder = InstDecoder::default(); + + let expected = "[MII] (p07) mov r16=r0; (p09) mov r14=r0;; purple;;"; + let data = [0xe3, 0x80, 0x00, 0x00, 0x00, 0x61, 0xe2, 0x00, 0x00, 0x00, 0x42, 0xc0, 0xe1, 0x80, 0x30, 0x00]; + let inst = decoder.decode(data[..].iter().cloned()).unwrap(); + assert_eq!(format!("{}", inst), expected); +} +#[test] fn test_shr_shl_dep_ext() { // encoding of immediates for dep/ext and their pseudo-ops (shl/shr) is weird. // `pos` is recorded as `63 - the_actual_value`? `len` is encoded as the actual length minus -- cgit v1.1