mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
port over the last two tests, partly
This commit is contained in:
parent
d5ce679b38
commit
6fbb22d9e4
@ -8,10 +8,12 @@ extern crate structopt;
|
||||
extern crate yansi;
|
||||
|
||||
mod map_conversion;
|
||||
mod parking;
|
||||
mod physics;
|
||||
mod runner;
|
||||
mod sim_completion;
|
||||
mod sim_determinism;
|
||||
mod transit;
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
@ -32,9 +34,11 @@ fn main() {
|
||||
let mut t = runner::TestRunner::new(flags.filter, flags.test_names);
|
||||
|
||||
map_conversion::run(t.suite("map_conversion"));
|
||||
parking::run(t.suite("parking"));
|
||||
physics::run(t.suite("physics"));
|
||||
sim_completion::run(t.suite("sim_completion"));
|
||||
sim_determinism::run(t.suite("sim_determinism"));
|
||||
transit::run(t.suite("transit"));
|
||||
|
||||
t.done();
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
/*extern crate abstutil;
|
||||
extern crate control;
|
||||
extern crate dimensioned;
|
||||
extern crate geom;
|
||||
extern crate map_model;
|
||||
extern crate sim;
|
||||
use runner::TestRunner;
|
||||
|
||||
use map_model::{BuildingID, LaneID};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
// TODO refactor a few more things to make these more succinct?
|
||||
pub fn run(_t: &mut TestRunner) {}
|
||||
|
||||
/*
|
||||
#[test]
|
||||
fn park_on_goal_st() {
|
||||
let (map, control_map, mut sim) = setup("park_on_goal_st", make_test_map());
|
||||
@ -148,4 +141,5 @@ fn triangle_around(x: f64, y: f64) -> Vec<geom::LonLat> {
|
||||
geom::LonLat::new(x + 5.0, y - 5.0),
|
||||
geom::LonLat::new(x, y + 5.0),
|
||||
]
|
||||
}*/
|
||||
}
|
||||
*/
|
@ -1,32 +1,37 @@
|
||||
extern crate abstutil;
|
||||
extern crate control;
|
||||
extern crate map_model;
|
||||
extern crate sim;
|
||||
use abstutil::Timer;
|
||||
use runner::TestRunner;
|
||||
use sim;
|
||||
use sim::{Event, SimFlags, Tick};
|
||||
|
||||
#[test]
|
||||
fn bus_reaches_stops() {
|
||||
let (map, control_map, mut sim) = sim::load(
|
||||
sim::SimFlags::for_test("bus_reaches_stops"),
|
||||
Some(sim::Tick::from_seconds(30)),
|
||||
&mut abstutil::Timer::new("setup test"),
|
||||
pub fn run(t: &mut TestRunner) {
|
||||
t.run_slow(
|
||||
"bus_reaches_stops",
|
||||
Box::new(|h| {
|
||||
let (map, control_map, mut sim) = sim::load(
|
||||
SimFlags::for_test("bus_reaches_stops"),
|
||||
Some(Tick::from_seconds(30)),
|
||||
&mut Timer::new("setup test"),
|
||||
);
|
||||
let route = map.get_bus_route("48").unwrap();
|
||||
let bus = sim.seed_bus_route(route, &map)[0];
|
||||
h.setup_done(&sim);
|
||||
|
||||
let mut expectations: Vec<Event> = Vec::new();
|
||||
// TODO assert stuff about other buses as well, although the timing is a little unclear
|
||||
for stop in route.stops.iter().skip(1) {
|
||||
expectations.push(Event::BusArrivedAtStop(bus, *stop));
|
||||
expectations.push(Event::BusDepartedFromStop(bus, *stop));
|
||||
}
|
||||
|
||||
sim.run_until_expectations_met(
|
||||
&map,
|
||||
&control_map,
|
||||
expectations,
|
||||
Tick::from_minutes(10),
|
||||
);
|
||||
sim.run_until_done(&map, &control_map, Box::new(|_sim| {}));
|
||||
}),
|
||||
);
|
||||
|
||||
let route = map.get_bus_route("48").unwrap();
|
||||
let bus = sim.seed_bus_route(route, &map)[0];
|
||||
let mut expectations: Vec<sim::Event> = Vec::new();
|
||||
// TODO assert stuff about other buses as well, although the timing is a little unclear
|
||||
for stop in route.stops.iter().skip(1) {
|
||||
expectations.push(sim::Event::BusArrivedAtStop(bus, *stop));
|
||||
expectations.push(sim::Event::BusDepartedFromStop(bus, *stop));
|
||||
}
|
||||
|
||||
sim.run_until_expectations_met(
|
||||
&map,
|
||||
&control_map,
|
||||
expectations,
|
||||
sim::Tick::from_minutes(10),
|
||||
);
|
||||
sim.run_until_done(&map, &control_map, Box::new(|_sim| {}));
|
||||
}
|
||||
|
||||
// TODO this test is strictly more complicated than bus_reaches_stops, should it subsume it?
|
Loading…
Reference in New Issue
Block a user