aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/armv7/thumb.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/armv7/thumb.rs b/tests/armv7/thumb.rs
index d9ecda6..c8b0b11 100644
--- a/tests/armv7/thumb.rs
+++ b/tests/armv7/thumb.rs
@@ -19,8 +19,8 @@ fn test_invalid_under(decoder: &InstDecoder, data: &[u8]) {
}
#[allow(dead_code)]
-fn test_display_under(decoder: &InstDecoder, data: [u8; 4], expected: &'static str) {
- let mut reader = yaxpeax_arch::U8Reader::new(&data[..]);
+fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str) {
+ let mut reader = yaxpeax_arch::U8Reader::new(data);
let instr = match decoder.decode(&mut reader) {
Err(e) => {
panic!("failed to decode {:#x?}: {}", data, e)
@@ -76,6 +76,20 @@ fn test_display(data: &[u8], expected: &'static str) {
);
}
+fn test_nonconforming(data: &[u8], expected: &'static str) {
+ let conforming = InstDecoder::default_thumb().allow_nonconforming(false);
+ let nonconforming = InstDecoder::default_thumb().allow_nonconforming(true);
+
+ let mut reader = yaxpeax_arch::U8Reader::new(&data[..]);
+ let result = conforming.decode(&mut reader);
+ assert!(
+ result.is_err(),
+ "got bad result: {:?} from {:#x?}", result, data
+ );
+
+ test_display_under(&nonconforming, data, expected);
+}
+
#[test]
fn test_unpredictable_instructions() {
test_invalid(&[0x80, 0xfa, 0x40, 0x00]);
@@ -1951,6 +1965,10 @@ fn test_decode_it_cases() {
&[0xef, 0xbf],
"iteee al"
);
+ test_nonconforming(
+ &[0xf7, 0xbf],
+ "ittee al",
+ );
}
#[test]
fn test_decode_ldm_16b_cases() {