add tests for instruction.rs

This commit is contained in:
Denis-Cosmin NUTIU 2024-12-01 23:10:46 +02:00
parent d8e221e05a
commit 3944ae36a8

View file

@ -24,3 +24,34 @@ impl Display for Instruction {
)) ))
} }
} }
impl PartialEq<u16> for Instruction {
fn eq(&self, other: &u16) -> bool {
self.data == *other
}
}
impl LowerHex for Instruction {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
fmt::LowerHex::fmt(&self.data, f)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_instruction_raw() {
let instruction = Instruction::new([0xffu8, 0xffu8]);
assert_eq!(instruction.raw(), 0xffffu16)
}
#[test]
fn test_instruction_partial_eq() {
let instruction = Instruction::new([0xffu8, 0xffu8]);
assert_eq!(instruction, 0xffffu16)
}
}