-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Expand file tree
/
Copy pathLineIntersectionTest.java
More file actions
34 lines (29 loc) · 1.34 KB
/
LineIntersectionTest.java
File metadata and controls
34 lines (29 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.thealgorithms.geometry;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class LineIntersectionTest {
@Test
void testIntersectingSegments() {
LineIntersection.Point p1 = new LineIntersection.Point(1, 1);
LineIntersection.Point q1 = new LineIntersection.Point(4, 4);
LineIntersection.Point p2 = new LineIntersection.Point(1, 4);
LineIntersection.Point q2 = new LineIntersection.Point(4, 1);
assertTrue(LineIntersection.doIntersect(p1, q1, p2, q2));
}
@Test
void testNonIntersectingSegments() {
LineIntersection.Point p1 = new LineIntersection.Point(1, 1);
LineIntersection.Point q1 = new LineIntersection.Point(2, 2);
LineIntersection.Point p2 = new LineIntersection.Point(3, 3);
LineIntersection.Point q2 = new LineIntersection.Point(4, 4);
assertFalse(LineIntersection.doIntersect(p1, q1, p2, q2));
}
@Test
void testCollinearOverlappingSegments() {
LineIntersection.Point p1 = new LineIntersection.Point(1, 1);
LineIntersection.Point q1 = new LineIntersection.Point(5, 5);
LineIntersection.Point p2 = new LineIntersection.Point(2, 2);
LineIntersection.Point q2 = new LineIntersection.Point(6, 6);
assertTrue(LineIntersection.doIntersect(p1, q1, p2, q2));
}
}