add test for beep
This commit is contained in:
parent
ebe913ec61
commit
7c566d4294
1 changed files with 21 additions and 0 deletions
|
@ -1026,4 +1026,25 @@ mod tests {
|
||||||
assert_eq!(emulator.sound_timer, 9);
|
assert_eq!(emulator.sound_timer, 9);
|
||||||
assert_eq!(emulator.delay_timer, 11);
|
assert_eq!(emulator.delay_timer, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_handle_timers_beep() {
|
||||||
|
struct TestSound {
|
||||||
|
did_beep: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SoundModule for TestSound {
|
||||||
|
fn beep(&mut self) {
|
||||||
|
self.did_beep = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let mut emulator = Emulator::new(TerminalDisplay::new(), TestSound { did_beep: false }, NoInput);
|
||||||
|
emulator.sound_timer = 0;
|
||||||
|
|
||||||
|
emulator.handle_timers();
|
||||||
|
|
||||||
|
assert_eq!(emulator.sound_module.did_beep, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue