ft: add first basic test

This commit is contained in:
2025-05-25 21:20:12 +09:00
parent 35207d23f0
commit 8ea91d80b8
4 changed files with 41 additions and 8 deletions

View File

@@ -829,3 +829,36 @@ impl Disassembler {
Ok(instructions)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_basic() {
let text = Vec::from([0x0, 0x0]);
let mut disassembler = Disassembler {
offset: 0,
text,
instruction: Instruction::new(),
};
let instructions = disassembler.decode_instructions().ok();
if let Some(instrs) = instructions {
assert_eq!(
instrs[0],
Instruction {
start: 0,
raw: Vec::from([0, 0]),
opcode: Mnemonic::ADD_FromReg(
ModRmTarget::Memory(MemoryIndex {
base: Some(Register::BX),
index: Some(Register::SI),
displacement: None
}),
Register::AL
)
}
)
}
}
}