add tests for instruction.rs
This commit is contained in:
parent
d8e221e05a
commit
3944ae36a8
1 changed files with 31 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue