diff options
author | iximeow <me@iximeow.net> | 2020-10-12 00:45:51 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2020-10-12 00:45:51 -0700 |
commit | c903c7ece85d22f3ee310ebaaa73241402e0be70 (patch) | |
tree | 28232af2755765560bc23da2daccd2569c2a97ff /tests/test.rs | |
parent | 50fb66e30c6bd696461fe0855f5f4a1a48e83faa (diff) |
do not panic on invalid instructions
Diffstat (limited to 'tests/test.rs')
-rw-r--r-- | tests/test.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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 |