Skip to content

Commit 3c93f22

Browse files
committed
test: add test for collinear points
1 parent e38d241 commit 3c93f22

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/algorithms/visibility.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,23 @@ mod tests {
145145
];
146146
assert_eq!(visiblity_polygon(&ls), correct);
147147
}
148+
149+
#[test]
150+
fn collinear_test() {
151+
let ls = vec![
152+
coord! { x: 0.0, y: 0.0 },
153+
coord! { x: 1.0, y: -2.0 },
154+
coord! { x: 2.0, y: 0.0 },
155+
coord! { x: 3.0, y: 0.0 },
156+
coord! { x: 4.0, y: -2.0 },
157+
coord! { x: 5.0, y: 0.0 },
158+
];
159+
let correct = vec![
160+
(0, coord! { x: 0.0, y: 0.0 }),
161+
(2, coord! { x: 2.0, y: 0.0 }),
162+
(3, coord! { x: 3.0, y: 0.0 }),
163+
(5, coord! { x: 5.0, y: 0.0 }),
164+
];
165+
assert_eq!(visiblity_polygon(&ls), correct);
166+
}
148167
}

0 commit comments

Comments
 (0)