Skip to content

Commit

Permalink
Add test for drawing line segment with zero length and remove dead co…
Browse files Browse the repository at this point in the history
…de from intersection_points
  • Loading branch information
theotherphil committed May 19, 2024
1 parent f210a9a commit e1e0f2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/drawing/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,21 @@ mod tests {
// 3 / | \ 0
// / 2 | 1 \

#[test]
fn test_draw_line_segment_zero_length() {
let image = GrayImage::from_pixel(5, 5, Luma([1u8]));

let expected = gray_image!(
1, 1, 1, 1, 1;
4, 1, 1, 1, 1;
1, 1, 1, 1, 1;
1, 1, 1, 1, 1;
1, 1, 1, 1, 1);

let actual = draw_line_segment(&image, (0f32, 1f32), (0f32, 1f32), Luma([4u8]));
assert_pixels_eq!(actual, expected);
}

#[test]
fn test_draw_line_segment_horizontal() {
let image = GrayImage::from_pixel(5, 5, Luma([1u8]));
Expand Down
3 changes: 0 additions & 3 deletions src/hough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ pub fn intersection_points(

if right_y >= 0.0 && right_y <= h {
let right_intersect = (w, right_y);
if let Some(s) = start {
return Some((s, right_intersect));
}
start = Some(right_intersect);
}

Expand Down

0 comments on commit e1e0f2b

Please sign in to comment.