mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
unit test that a sim finishes eventually
This commit is contained in:
parent
44239588c8
commit
6d70605355
@ -400,6 +400,12 @@ impl Sim {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_done(&self) -> bool {
|
||||
let (_, active_cars) = self.driving_state.get_active_and_waiting_count();
|
||||
let (_, active_peds) = self.walking_state.get_active_and_waiting_count();
|
||||
active_cars == 0 && active_peds == 0
|
||||
}
|
||||
|
||||
pub fn debug_ped(&self, id: PedestrianID) {
|
||||
self.walking_state.debug_ped(id);
|
||||
}
|
||||
|
30
sim/tests/completion.rs
Normal file
30
sim/tests/completion.rs
Normal file
@ -0,0 +1,30 @@
|
||||
extern crate abstutil;
|
||||
extern crate control;
|
||||
extern crate map_model;
|
||||
extern crate sim;
|
||||
|
||||
#[test]
|
||||
fn aorta_model_completes() {
|
||||
// This assumes this map has been built
|
||||
let input = "../data/small.abst";
|
||||
let rng_seed = 42;
|
||||
let spawn_count = 100;
|
||||
|
||||
let map = map_model::Map::new(input, &map_model::Edits::new()).expect("Couldn't load map");
|
||||
let control_map = control::ControlMap::new(&map);
|
||||
|
||||
let mut sim = sim::Sim::new(&map, Some(rng_seed), false);
|
||||
sim.seed_pedestrians(&map, spawn_count);
|
||||
sim.seed_parked_cars(0.5);
|
||||
sim.start_many_parked_cars(&map, spawn_count);
|
||||
|
||||
loop {
|
||||
sim.step(&map, &control_map);
|
||||
if sim.time.is_multiple_of_minute() {
|
||||
println!("{}", sim.summary());
|
||||
}
|
||||
if sim.is_done() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user