Add tests, fix offset logic, and bump dependencies

- Introduce a comprehensive test suite (cli, app, board, tasks, audio)
  and a
  new TESTING.md document describing test execution.
- Correct vertical offset calculation in `BoardState` to use saturating
  subtraction and ceiling division.
- Clamp initial `Offset` values to the provided maximum in
  `Offset::new`.
- Export `load_audio` from the audio thread module and switch to
  `LoopedDecoder` for proper OGG looping.
- Update several crate versions: clap, ratatui, log, rodio, and
  bitflags.
This commit is contained in:
GarandPLG committed 2026-10-18 20:29:04 +02:00
1 parent 9bc42dc898
commit fcdbbaf74c
16 files changed
+817 -246

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
use war_in_tunnels::app::states::skirmish_states::{
Players,
tasks::{DiggingTask, Task, Tasks},
units::{MinerUnit, Unit},
};
#[test]
fn digging_progress_accumulates_and_stops_at_completion() {
let mut task = DiggingTask::new([(5, 3)].into(), 40.0);
assert!(!task.is_finished());
task.progress();
assert_eq!(task.get_progress(), 40.0);
assert!(!task.is_finished());
for _ in 0..3 {
task.progress();
}
assert_eq!(task.get_progress(), 100.0);
assert!(task.is_finished());
}
#[test]
fn advancing_path_resets_progress_and_handles_empty_path() {
let mut task = DiggingTask::new([(5, 3), (5, 4)].into(), 25.0);
task.progress();
task.pop_front();
assert_eq!(task.current_target(), Some((5, 4)));
assert_eq!(task.get_progress(), 0.0);
task.pop_front();
task.pop_front();
assert_eq!(task.current_target(), None);
assert!(task.get_path().is_empty());
}
#[test]
fn miners_keep_tasks_in_submission_order() {
let mut miner = MinerUnit::new(Players::Player, (5, 2));
for target in [(5, 3), (6, 3)] {
miner.set_task(Tasks::Digging(DiggingTask::new([target].into(), 1.0)));
}
assert_eq!(miner.get_ref_tasks().len(), 2);
assert_eq!(
*miner
.get_mut_tasks()
.pop_front()
.unwrap()
.get_path_front_coords(),
(5, 3)
);
assert_eq!(*miner.get_ref_tasks()[0].get_path_front_coords(), (6, 3));
}