trevors_chip8_toy/gemma/tests/sound_timer.rs
2025-05-31 22:56:05 -04:00

32 lines
557 B
Rust

use gemma::chip8::sound_timer::SoundTimer;
/// Tests for The Sound Timer
///
///
#[test]
fn sound_timer_default() {
let x = SoundTimer::default();
assert_eq!(x.current(), 0);
}
#[test]
fn sound_timer_ticks_reduce_time() {
let mut st = SoundTimer::new();
st.set_timer(100);
st.tick();
st.tick();
st.tick();
assert_eq!(st.current(), 97);
}
#[test]
fn sound_timer_out_of_ticks_works() {
let mut st = SoundTimer::new();
st.set_timer(0);
st.tick();
st.tick();
st.tick();
assert_eq!(st.current(), 0);
}