From 35222d0f9f33e86a6046fad1f0d6a7e09656016b Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 21 Jan 2022 18:25:40 -0800 Subject: add test that the nd812 disassembler does not panic --- tests/test.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index d2750ee..a0e200b 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -27,6 +27,26 @@ fn test_display(data: &[u16], expected: &'static str) { } #[test] +fn test_decoder_does_not_panic() { + for i in 0..0o7777_7777 { + let low = (i & 0o7777) as u16; + let high = (i >> 12) as u16; + let data = &[low, high]; + let mut reader = yaxpeax_nd812::ND812Reader::of_u16(data); + match yaxpeax_nd812::InstDecoder::default().decode(&mut reader) { + Ok(instr) => { + let displayed = instr.to_string(); + assert!(displayed.len() > 0); + } + Err(e) => { + let displayed = e.to_string(); + assert!(displayed.len() > 0); + } + } + + } +} +#[test] fn test_disassembly() { test_display(&[0o5464], "stj $+0x34"); // symbol name from IM41-1085 test_display(&[0o6137], "jmp $-0x1f"); // symbol name from IM41-1085 -- cgit v1.1