77import java .util .Arrays ;
88import java .util .List ;
99import java .util .stream .Stream ;
10-
1110import org .junit .jupiter .api .Test ;
1211import org .junit .jupiter .params .ParameterizedTest ;
1312import org .junit .jupiter .params .provider .Arguments ;
@@ -24,7 +23,44 @@ void testMergeParameterizedScenarios(List<Integer> listA, List<Integer> listB, L
2423 }
2524
2625 private static Stream <Arguments > provideMergeTestData () {
27- return Stream .of (Arguments .of (Arrays .asList (1 , 3 , 5 , 7 , 9 ), Arrays .asList (2 , 4 , 6 , 8 , 10 ), Arrays .asList (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ), "Standard alternating sorted lists" ), Arguments .of (Arrays .asList (1 , 2 , 3 ), new ArrayList <>(), Arrays .asList (1 , 2 , 3 ), "Merge with empty second list" ), Arguments .of (new ArrayList <>(), Arrays .asList (4 , 5 , 6 ), Arrays .asList (4 , 5 , 6 ), "Merge with empty first list" ), Arguments .of (new ArrayList <>(), new ArrayList <>(), new ArrayList <>(), "Merge with both lists empty" ), Arguments .of (Arrays .asList (1 , 2 , 2 , 3 ), Arrays .asList (2 , 3 , 4 ), Arrays .asList (1 , 2 , 2 , 2 , 3 , 3 , 4 ), "Handling duplicate elements gracefully" ), Arguments .of (Arrays .asList (-3 , -1 , 2 ), Arrays .asList (-2 , 0 , 3 ), Arrays .asList (-3 , -2 , -1 , 0 , 2 , 3 ), "Handling negative numbers mixed with positive numbers" ));
26+ return Stream .of (
27+ Arguments .of (
28+ Arrays .asList (1 , 3 , 5 , 7 , 9 ),
29+ Arrays .asList (2 , 4 , 6 , 8 , 10 ),
30+ Arrays .asList (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ),
31+ "Standard alternating sorted lists"
32+ ),
33+ Arguments .of (
34+ Arrays .asList (1 , 2 , 3 ),
35+ new ArrayList <>(),
36+ Arrays .asList (1 , 2 , 3 ),
37+ "Merge with empty second list"
38+ ),
39+ Arguments .of (
40+ new ArrayList <>(),
41+ Arrays .asList (4 , 5 , 6 ),
42+ Arrays .asList (4 , 5 , 6 ),
43+ "Merge with empty first list"
44+ ),
45+ Arguments .of (
46+ new ArrayList <>(),
47+ new ArrayList <>(),
48+ new ArrayList <>(),
49+ "Merge with both lists empty"
50+ ),
51+ Arguments .of (
52+ Arrays .asList (1 , 2 , 2 , 3 ),
53+ Arrays .asList (2 , 3 , 4 ),
54+ Arrays .asList (1 , 2 , 2 , 2 , 3 , 3 , 4 ),
55+ "Handling duplicate elements gracefully"
56+ ),
57+ Arguments .of (
58+ Arrays .asList (-3 , -1 , 2 ),
59+ Arrays .asList (-2 , 0 , 3 ),
60+ Arrays .asList (-3 , -2 , -1 , 0 , 2 , 3 ),
61+ "Handling negative numbers mixed with positive numbers"
62+ )
63+ );
2864 }
2965
3066 @ Test
@@ -47,4 +83,4 @@ void testMergeThrowsExceptionWhenResultCollectionIsNull() {
4783 List <Integer > listB = Arrays .asList (4 , 5 , 6 );
4884 assertThrows (NullPointerException .class , () -> MergeSortedArrayList .merge (listA , listB , null ));
4985 }
50- }
86+ }
0 commit comments