-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Expand file tree
/
Copy pathConvexHullTest.java
More file actions
28 lines (22 loc) · 940 Bytes
/
ConvexHullTest.java
File metadata and controls
28 lines (22 loc) · 940 Bytes
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
package com.thealgorithms.geometry;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ConvexHullTest {
@Test
public void testConvexHull() {
List<Point> points =
Arrays.asList(new Point(0, 3), new Point(2, 2), new Point(1, 1), new Point(2, 1), new Point(3, 0),
new Point(0, 0), new Point(3, 3), new Point(2, -1), new Point(2, -4), new Point(1, -3));
Set<Point> expected = new HashSet<>(
Arrays.asList(new Point(2, -4), new Point(1, -3), new Point(0, 0), new Point(3, 0), new Point(0, 3),
new Point(3, 3))
);
List<Point> hull = ConvexHull.convexHullRecursive(points);
Set<Point> actual = new HashSet<>(hull);
assertEquals(expected, actual);
}
}