Test interrupted return pickup
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
@@ -318,6 +318,32 @@ mod tests {
|
||||
assert!(!sim.sams[2].return_cargo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_waits_for_moving_or_damaged_units() {
|
||||
let mut sim = Sim::new(4);
|
||||
for (kind, x) in [(SamKind::Depot, 0.0), (SamKind::S400, 160.0), (SamKind::Tzm, 160.0)] {
|
||||
let id = sim.id(); sim.sams.push(Sam::new(id, kind, DVec3::new(x, 70.0, 0.0), 0.0));
|
||||
}
|
||||
sim.sams[1].ground_rounds = 1;
|
||||
sim.sams[1].missiles = 3;
|
||||
sim.unload_ground_round(1).unwrap();
|
||||
sim.tick = 2;
|
||||
sim.sams[1].comps.0[Part::Launcher as usize] = 0.0;
|
||||
sim.step_supply(&mut Out::default());
|
||||
assert_eq!(sim.sams[1].ground_rounds, 1);
|
||||
sim.sams[1].comps.0[Part::Launcher as usize] = 1.0;
|
||||
sim.sams[2].comps.0[Part::Tracks as usize] = 0.0;
|
||||
sim.step_supply(&mut Out::default());
|
||||
assert_eq!(sim.sams[1].ground_rounds, 1);
|
||||
sim.sams[2].comps.0[Part::Tracks as usize] = 1.0;
|
||||
assert!(sim.order_move(1, DVec3::new(220.0, 70.0, 0.0)));
|
||||
sim.step_supply(&mut Out::default());
|
||||
assert_eq!(sim.sams[1].ground_rounds, 1);
|
||||
sim.sams[1].state = SamState::Search;
|
||||
sim.step_supply(&mut Out::default());
|
||||
assert_eq!((sim.sams[1].ground_rounds, sim.sams[2].ground_stock), (0, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_delivery_uses_stock_and_shared_cells_and_survives_interruption() {
|
||||
let mut sim = Sim::new(1);
|
||||
|
||||
Reference in New Issue
Block a user