-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndexofSum.test.java
44 lines (32 loc) · 1.18 KB
/
IndexofSum.test.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class IndexofSumTest {
@Test
public void testGetIndexOfSum_ValidPairExists() {
List<Integer> list = Arrays.asList(1, 2, 3, 6);
List<Integer> result = IndexofSum.getIndexOfSum(list, 5);
assertArrayEquals(new Integer[]{1, 2}, result.toArray());
}
@Test
public void testGetIndexOfSum_NoValidPair() {
List<Integer> list = Arrays.asList(1, 2, 3, 6);
List<Integer> result = IndexofSum.getIndexOfSum(list, 10);
assertNull(result);
}
@Test
public void testGetIndexOfSum_EmptyList() {
List<Integer> list = Arrays.asList();
List<Integer> result = IndexofSum.getIndexOfSum(list, 5);
assertNull(result);
}
@Test
public void testGetIndexOfSum_OnlyOneValidNumber() {
List<Integer> list = Arrays.asList(1, 2, 3, 6);
List<Integer> result = IndexofSum.getIndexOfSum(list, 2);
assertNull(result);
}
// ... Additional test cases as necessary ...
}