Skip to content

Commit

Permalink
fixup! editoast: increase the number of tests for projection
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed Dec 19, 2024
1 parent dc7094b commit 3750ea8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions editoast/src/views/path/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ mod tests {
);
}

// To invert track ranges, we need to get the list of track ranges
// backwards, and toggle the direction for each track range
fn invert_track_ranges(
track_ranges: impl DoubleEndedIterator<Item = TrackRange>,
) -> Vec<TrackRange> {
Expand All @@ -420,6 +422,17 @@ mod tests {
.collect()
}

// To invert the intersection, we need to get the intersection backwards,
// invert each tuple and change the offsets by subtracting them from
// the total length of the projection path.
//
// For example, let's project "A+120-140" on a path "A+100-200", it will
// give the intersection (20, 40). If we invert the projection path (from
// "A+100-200" into "A+200-100"), we then get an intersection (60, 80).
// This new result can be calculated by:
// - calculating the length of the projection path: 200 - 100 = 100
// - inverting the original tuple: (20, 40) -> (40, 20)
// - subtracting from the length: (100-40, 100-20) = (60, 80)
fn invert_intersections(
intersections: impl DoubleEndedIterator<Item = Intersection>,
path_length: u64,
Expand Down Expand Up @@ -467,7 +480,10 @@ mod tests {
#[case] path: &[&str],
#[case] track_ranges: &[&str],
#[case] expected_intersections: &[(u64, u64)],
// If we invert the projected track ranges, it doesn't change the intersection
#[values(false, true)] toggle_path: bool,
// If we invert the projection path, the intersections will be backwards
// and the offsets will be subtracted from the total length
#[values(false, true)] toggle_track_ranges: bool,
) {
let path = path.into_iter().map(|s| s.parse().unwrap());
Expand Down

0 comments on commit 3750ea8

Please sign in to comment.