Skip to content

Commit

Permalink
clippy and intersection.report inverse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jan 22, 2024
1 parent 9196db1 commit 354bef2
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/intersections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ impl Intersections {
}
}
}
if a_mode.contains(IntersectionMode::Not) && self.overlapping.len() == 0 {
self.push_overlap_fragments(&mut result, &vec![], a_part, b_part, usize::MAX);
if a_mode.contains(IntersectionMode::Not) && self.overlapping.is_empty() {
self.push_overlap_fragments(&mut result, &[], a_part, b_part, usize::MAX);
}

Report::new(result)
Expand Down Expand Up @@ -494,6 +494,44 @@ mod tests {
eprintln!("{:?}", r);
}

#[test]
fn test_a_not() {
let intersections = make_example("a: 1-10\nb: 3-4, 6-7, 8-12\nb:9-20");
let r = intersections.report(
&IntersectionMode::Not,
&IntersectionMode::Default,
&IntersectionPart::Whole,
&IntersectionPart::Whole,
&OverlapAmount::Bases(1),
&OverlapAmount::Bases(1),
);
assert!(r.len() == 0);
let r = intersections.report(
&IntersectionMode::Not,
&IntersectionMode::Default,
&IntersectionPart::Whole,
&IntersectionPart::Whole,
&OverlapAmount::Bases(6),
&OverlapAmount::Bases(1),
);
assert_eq!(r.len(), 2);
}

#[test]
fn test_a_not_with_empty() {
let intersections = make_example("a: 1-10");
let r = intersections.report(
&IntersectionMode::Not,
&IntersectionMode::Default,
&IntersectionPart::Whole,
&IntersectionPart::Whole,
&OverlapAmount::Bases(1),
&OverlapAmount::Bases(1),
);
assert_eq!(1, r.len());
assert_eq!(r[0].id, usize::MAX);
}

#[test]
fn test_b_inverse() {
let intersections = make_example("a: 1-10\nb: 3-4, 6-7, 8-12\nb:9-20");
Expand Down

0 comments on commit 354bef2

Please sign in to comment.