44import static org .junit .jupiter .api .Assertions .assertThrows ;
55import static org .junit .jupiter .api .Assertions .assertTrue ;
66
7+ import com .thealgorithms .randomized .RandomizedClosestPair .Point ;
78import java .lang .reflect .Constructor ;
89import java .lang .reflect .InvocationTargetException ;
9-
10- import com .thealgorithms .randomized .RandomizedClosestPair .Point ;
1110import org .junit .jupiter .api .Test ;
1211
1312public class RandomizedClosestPairTest {
1413
1514 @ Test
1615 public void testFindClosestPairDistance () {
17- Point [] points = { new Point (1 , 1 ), new Point (2 , 2 ), new Point (3 , 3 ), new Point (8 , 8 ), new Point (13 , 13 ) };
16+ Point [] points = {new Point (1 , 1 ), new Point (2 , 2 ), new Point (3 , 3 ), new Point (8 , 8 ), new Point (13 , 13 )};
1817 double result = RandomizedClosestPair .findClosestPairDistance (points );
1918 assertEquals (Math .sqrt (2 ), result , 0.00001 );
2019 }
2120
2221 @ Test
2322 public void testWithIdenticalPoints () {
24- Point [] points = { new Point (0 , 0 ), new Point (0 , 0 ), new Point (1 , 1 ) };
23+ Point [] points = {new Point (0 , 0 ), new Point (0 , 0 ), new Point (1 , 1 )};
2524 double result = RandomizedClosestPair .findClosestPairDistance (points );
2625 assertEquals (0.0 , result , 0.00001 );
2726 }
2827
2928 @ Test
3029 public void testWithDistantPoints () {
31- Point [] points = { new Point (0 , 0 ), new Point (5 , 0 ), new Point (10 , 0 ) };
30+ Point [] points = {new Point (0 , 0 ), new Point (5 , 0 ), new Point (10 , 0 )};
3231 double result = RandomizedClosestPair .findClosestPairDistance (points );
3332 assertEquals (5.0 , result , 0.00001 );
3433 }
@@ -42,11 +41,7 @@ public void testPrivateConstructor() throws Exception {
4241
4342 @ Test
4443 public void testStripConditionCoverage () {
45- Point [] points = {
46- new Point (0 , 0 ),
47- new Point (0.001 , 0.001 ),
48- new Point (0.002 , 0.002 )
49- };
44+ Point [] points = {new Point (0 , 0 ), new Point (0.001 , 0.001 ), new Point (0.002 , 0.002 )};
5045 double result = RandomizedClosestPair .findClosestPairDistance (points );
5146 assertTrue (result < 0.01 ); // distance should be covered by strip logic
5247 }
0 commit comments