applogic: Fix maneuver ordering
This commit is contained in:
parent
f0339f6261
commit
6c9cbbd6e6
1 changed files with 21 additions and 2 deletions
|
|
@ -534,9 +534,12 @@ impl Ord for Maneuvers {
|
|||
core::cmp::Ordering::Greater
|
||||
}
|
||||
}
|
||||
// (only straight) > omni
|
||||
// (only straight) > omni or left or left+straight
|
||||
(false, true, false) => {
|
||||
if other.eq(&Maneuvers::new(true, true, true)) {
|
||||
if other.eq(&Maneuvers::new(true, true, true))
|
||||
|| other.eq(&Maneuvers::new(true, false, false))
|
||||
|| other.eq(&Maneuvers::new(true, true, false))
|
||||
{
|
||||
core::cmp::Ordering::Greater
|
||||
} else {
|
||||
core::cmp::Ordering::Less
|
||||
|
|
@ -1030,5 +1033,21 @@ mod tests {
|
|||
assert_eq!(straight, sorted[3]);
|
||||
assert_eq!(straight_and_right, sorted[4]);
|
||||
assert_eq!(right, sorted[5]);
|
||||
|
||||
// was a bug at 2026-06-21
|
||||
let maneuvers = vec![right, left, straight_and_left, straight];
|
||||
|
||||
let mut sorted = maneuvers.clone();
|
||||
sorted.sort();
|
||||
|
||||
println!("Sorted maneuvers:");
|
||||
for manv in &sorted {
|
||||
println!("- {manv}");
|
||||
}
|
||||
|
||||
assert_eq!(left, sorted[0]);
|
||||
assert_eq!(straight_and_left, sorted[1]);
|
||||
assert_eq!(straight, sorted[2]);
|
||||
assert_eq!(right, sorted[3]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue