Skip to content

Commit

Permalink
fixing and prettifying tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snf committed Mar 16, 2016
1 parent 1c1ebc5 commit 1bf2831
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ pub use assembler::{Arch, Reloc, assemble, assemble2};

#[test]
fn x86_int3() {
//assert_eq!(assemble(Arch::X86, "int3").unwrap(), [0xcc]);
assert_eq!(assemble(Arch::X86, "int3").unwrap(), [0xcc]);
}

#[test]
fn x86_jcc() {
let bytes = assemble(Arch::X86_64, "nop; jz here; nop; nop; here:").expect("couldn't compile the code");
let bytes = assemble(Arch::X86_64, "nop; jz here; nop; nop; here:").unwrap();
assert_eq!(bytes, [0x90, 0x74, 0x02, 0x90, 0x90]);
}

#[test]
fn x86_jmp_rel() {
let addr = 0x1000;
let reloc = Reloc::new("here", 0x1003);
let bytes = assemble2(Arch::X86_64, "jmp here", addr, &[reloc]).expect("couldn't compile the code");
let bytes = assemble2(Arch::X86_64, "jmp here", addr, &[reloc]).unwrap();
assert_eq!(bytes, [0xeb, 0x01]);
}

#[test]
fn missing_label() {
assert_eq!(assemble(Arch::X86_64, "jz here"), None);
}

0 comments on commit 1bf2831

Please sign in to comment.