Skip to content

Commit

Permalink
Clarify test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mbattifarano committed Jun 20, 2017
1 parent 51a4efd commit 6c3ea2f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/algorithm/intersects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,20 +442,34 @@ mod test {
#[test]
fn point_intersects_line_test() {
let p0 = Point::new(2., 4.);
let p1 = Point::new(0., 0.);
// vertical line
let line1 = Line::new(Point::new(2., 0.), Point::new(2., 5.));
// point on line, but outside line segment
let line2 = Line::new(Point::new(0., 6.), Point::new(1.5, 4.5));
// point on line
let line3 = Line::new(Point::new(0., 6.), Point::new(3., 3.));
// point above line with positive slope
let line4 = Line::new(Point::new(1., 2.), Point::new(5., 3.));
// point below line with positive slope
let line5 = Line::new(Point::new(1., 5.), Point::new(5., 6.));
// point above line with negative slope
let line6 = Line::new(Point::new(1., 2.), Point::new(5., -3.));
// point below line with negative slope
let line7 = Line::new(Point::new(1., 6.), Point::new(5., 5.));
assert!(line1.intersects(&p0));
assert!(p0.intersects(&line1));
assert!(!line2.intersects(&p0));
assert!(!p0.intersects(&line2));
assert!(line3.intersects(&p0));
assert!(p0.intersects(&line3));
assert!(!p1.intersects(&line3));
assert!(!line4.intersects(&p0));
assert!(!p0.intersects(&line4));
assert!(!line5.intersects(&p0));
assert!(!p0.intersects(&line5));
assert!(!line6.intersects(&p0));
assert!(!p0.intersects(&line6));
assert!(!line7.intersects(&p0));
assert!(!p0.intersects(&line7));
}
#[test]
fn line_intersects_line_test() {
Expand Down

0 comments on commit 6c3ea2f

Please sign in to comment.