diff --git a/src/lib.rs b/src/lib.rs index b82a941..a5ab04c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -256,4 +256,16 @@ mod tests { let path = BezPath::from_svg(path).unwrap(); Topology::from_path(&path, 0.001).unwrap(); } + + #[test] + fn empty_paths() { + let contours = binary_op( + &BezPath::new(), + &BezPath::new(), + FillRule::EvenOdd, + BinaryOp::Xor, + ) + .unwrap(); + assert!(contours.contours().next().is_none()); + } } diff --git a/src/sweep/sweep_line.rs b/src/sweep/sweep_line.rs index 60d2a6b..ac7baa7 100644 --- a/src/sweep/sweep_line.rs +++ b/src/sweep/sweep_line.rs @@ -317,7 +317,7 @@ impl<'segs> Sweeper<'segs> { Sweeper { eps, line: SegmentOrder::default(), - y: events.next_y(segments).unwrap(), + y: events.next_y(segments).unwrap_or(f64::INFINITY), events, segments, segs_needing_positions: Vec::new(), @@ -1932,6 +1932,14 @@ mod tests { insta::assert_ron_snapshot!(snapshot_outputs(segs, 0.25)); } + #[test] + fn empty_sweep_line() { + let segs = Segments::default(); + let mut sweep = Sweeper::new(&segs, 1.0); + let mut bufs = SweepLineBuffers::default(); + assert!(sweep.next_line(&mut bufs).is_none()); + } + proptest! { #[test] fn perturbation_test_f64(perturbations in prop::collection::vec(perturbation(f64_perturbation(0.1)), 1..5)) {