11package com .thealgorithms .shufflealgorithm ;
22
3- import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
4- import static org .junit .jupiter .api .Assertions .assertTrue ;
5-
63import com .thealgorithms .shufflealogrithm .WeightedShuffle ;
74import org .junit .jupiter .api .Test ;
85
6+ import static org .junit .jupiter .api .Assertions .*;
7+
98public class WeightedShuffleTest {
109
1110 // Test case for matching array and weights
@@ -15,14 +14,11 @@ void testWeightedShuffleBasic() {
1514 int [] weights = {1 , 3 , 2 };
1615 WeightedShuffle .weightedShuffle (array , weights );
1716
18- // After shuffling, higher weight elements should be more likely to appear
19- // earlier The expected order can be difficult to determine precisely, but
20- // we can check if the higher-weight elements (20, weight 3) appear before
21- // lower-weight ones (10, weight 1).
22- assertTrue (array [0 ] == 20 || array [1 ] == 20 ,
23- "20 should be among the first two elements" );
24- assertTrue (array [0 ] == 10 || array [1 ] == 10 ,
25- "10 should not be the first element" );
17+ // Check that higher weight element (20) appears among the first two elements
18+ assertTrue (array [0 ] == 20 || array [1 ] == 20 , "20 should be among the first two elements" );
19+
20+ // Check that lower weight element (10) is not in the first position
21+ assertFalse (array [0 ] == 10 , "10 should not be the first element" );
2622 }
2723
2824 // Test case for empty array
0 commit comments