Skip to content

Commit 93a5505

Browse files
Add unit test for ClosestPairOfPoints class
1 parent de42132 commit 93a5505

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.thealgorithms.geometry;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
import java.util.Arrays;
5+
import org.junit.jupiter.api.Test;
6+
7+
public class ClosestPairOfPointsTest {
8+
@Test
9+
void testClosestPair() {
10+
var pts = Arrays.asList(
11+
new Point(2, 3), new Point(12, 30),
12+
new Point(40, 50), new Point(5, 1),
13+
new Point(12, 10), new Point(3, 4)
14+
);
15+
double result = ClosestPairOfPoints.closestPair(pts);
16+
assertEquals(Math.sqrt(2), result, 1e-6);
17+
}
18+
}

0 commit comments

Comments
 (0)