1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
mod add_bike_lanes;
mod add_new_lane;
mod one_ways;
use geom::Distance;
use crate::{Direction, LaneSpec, LaneType};
impl LaneSpec {
pub fn create_for_test(input_lt: &str, input_dir: &str) -> Vec<LaneSpec> {
assert_eq!(input_lt.len(), input_dir.len());
input_lt
.chars()
.zip(input_dir.chars())
.map(|(lt, dir)| LaneSpec {
lt: LaneType::from_char(lt),
dir: if dir == '^' {
Direction::Fwd
} else {
Direction::Back
},
width: Distance::ZERO,
})
.collect()
}
pub fn check_lanes_ltr(
actual_lanes_ltr: &[LaneSpec],
description: String,
input_lt: &str,
input_dir: &str,
expected_lt: &str,
expected_dir: &str,
ok: &mut bool,
) {
let actual_lt: String = actual_lanes_ltr.iter().map(|s| s.lt.to_char()).collect();
let actual_dir: String = actual_lanes_ltr
.iter()
.map(|s| if s.dir == Direction::Fwd { '^' } else { 'v' })
.collect();
if actual_lt != expected_lt || actual_dir != expected_dir {
*ok = false;
println!("{}", description);
println!("Input:");
println!(" {}", input_lt);
println!(" {}", input_dir);
println!("Got:");
println!(" {}", actual_lt);
println!(" {}", actual_dir);
println!("Expected:");
println!(" {}", expected_lt);
println!(" {}", expected_dir);
println!();
}
}
}