aboutsummaryrefslogtreecommitdiff
path: root/test/armv7/thumb.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-07-06 16:42:24 -0700
committeriximeow <me@iximeow.net>2021-07-06 16:43:02 -0700
commit61513023aff4d3312287bb0fb55ea931997dfddb (patch)
tree51c07a11570d5012f68929e9c44a7fc2df97b15e /test/armv7/thumb.rs
parentc75153a5efffcd2ac5f37864182e5108ea5f70ce (diff)
update yaxpeax_arch and bump version to 0.1.00.1.0
Diffstat (limited to 'test/armv7/thumb.rs')
-rw-r--r--test/armv7/thumb.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/armv7/thumb.rs b/test/armv7/thumb.rs
index b603925..4c5c4a1 100644
--- a/test/armv7/thumb.rs
+++ b/test/armv7/thumb.rs
@@ -5,7 +5,8 @@ type InstDecoder = <ARMv7 as Arch>::Decoder;
#[allow(dead_code)]
fn test_invalid_under(decoder: &InstDecoder, data: &[u8]) {
- match decoder.decode(data.to_vec()) {
+ let mut reader = yaxpeax_arch::U8Reader::new(&data[..]);
+ match decoder.decode(&mut reader) {
Err(_) => { },
Ok(inst) => {
panic!(
@@ -19,7 +20,13 @@ fn test_invalid_under(decoder: &InstDecoder, data: &[u8]) {
#[allow(dead_code)]
fn test_display_under(decoder: &InstDecoder, data: [u8; 4], expected: &'static str) {
- let instr = decoder.decode(data.to_vec()).unwrap_or_else(|_| panic!("failed to decode {:#x?}", data));
+ let mut reader = yaxpeax_arch::U8Reader::new(&data[..]);
+ let instr = match decoder.decode(&mut reader) {
+ Err(e) => {
+ panic!("failed to decode {:#x?}: {}", data, e)
+ }
+ Ok(instr) => instr,
+ };
let displayed = format!("{}", instr);
assert!(
displayed == expected,
@@ -31,7 +38,13 @@ fn test_display_under(decoder: &InstDecoder, data: [u8; 4], expected: &'static s
#[allow(dead_code)]
fn test_decode(data: &[u8], expected: Instruction) {
- let instr = InstDecoder::default_thumb().decode(data.to_vec()).unwrap();
+ let mut reader = yaxpeax_arch::U8Reader::new(data);
+ let instr = match InstDecoder::default_thumb().decode(&mut reader) {
+ Err(e) => {
+ panic!("failed to decode {:#x?}: {}", data, e)
+ }
+ Ok(instr) => instr,
+ };
assert!(
instr == expected,
"decode error for {:#x?}:\n decoded: {:?}\n expected: {:?}\n",
@@ -42,11 +55,17 @@ fn test_decode(data: &[u8], expected: Instruction) {
#[allow(dead_code)]
fn test_invalid(data: &[u8]) {
- test_invalid_under(&InstDecoder::default(), data);
+ test_invalid_under(&InstDecoder::default_thumb(), data);
}
fn test_display(data: &[u8], expected: &'static str) {
- let instr = InstDecoder::default_thumb().decode(data.to_vec()).unwrap();
+ let mut reader = yaxpeax_arch::U8Reader::new(data);
+ let instr = match InstDecoder::default_thumb().decode(&mut reader) {
+ Err(e) => {
+ panic!("failed to decode {:#x?}: {}", data, e)
+ }
+ Ok(instr) => instr,
+ };
let text = format!("{}", instr);
assert!(
text == expected,