summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-03-20 14:43:05 -0700
committeriximeow <me@iximeow.net>2020-01-12 17:07:40 -0800
commit091373f8077053f0ccdf7fa6e70b9e33db802cc8 (patch)
tree1ce95021084f22216d692603b914fe447ff6a5fa
parente380a481b8f129b50ee49be818ad889bedcd3b2f (diff)
these tests existed but i forgot to commit them before, oops
-rw-r--r--test/test.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test.rs b/test/test.rs
new file mode 100644
index 0000000..48cf90b
--- /dev/null
+++ b/test/test.rs
@@ -0,0 +1,28 @@
+extern crate yaxpeax_arch;
+extern crate yaxpeax_msp430_mc;
+
+use yaxpeax_arch::Decodable;
+use yaxpeax_msp430_mc::{Instruction, Opcode};
+
+#[test]
+fn test_decode() {
+ let data = [0x02, 0x12];
+ let mut instr = Instruction::blank();
+ instr.decode_into(data.iter().map(|x| *x));
+ assert!(instr.opcode == Opcode::PUSH);
+
+ let data = [0xb1, 0x92, 0x8d, 0x49];
+ let mut instr = Instruction::blank();
+ instr.decode_into(data.iter().map(|x| *x));
+ assert!(instr.opcode == Opcode::CMP);
+
+ let data = [0x12, 0x00, 0x3f, 0x40];
+ let mut instr = Instruction::blank();
+ instr.decode_into(data.iter().map(|x| *x));
+ assert!(instr.opcode == Opcode::RRC);
+
+ let data = [0x20, 0x0e];
+ let mut instr = Instruction::blank();
+ instr.decode_into(data.iter().map(|x| *x));
+ assert!(instr.opcode == Opcode::PUSH);
+}