-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreeSumZeroTest.java
More file actions
executable file
·58 lines (43 loc) · 1.53 KB
/
Copy pathThreeSumZeroTest.java
File metadata and controls
executable file
·58 lines (43 loc) · 1.53 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package algorithm.exercises;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
class ThreeSumZeroTest {
@Test
void testA() {
ThreeSumZero threeSumZero = new ThreeSumZero();
int[] arr = {3, 5, 8, 10, -9, -11, 16, 2};
List<List<Integer>> result = threeSumZero.threeSum(arr);
Assertions.assertEquals(1, result.size());
Assertions.assertEquals(List.of(-11, 3, 8), result.get(0));
}
@Test
void testB() {
ThreeSumZero threeSumZero = new ThreeSumZero();
int[] arr = {0, 0, 0};
List<List<Integer>> result = threeSumZero.threeSum(arr);
Assertions.assertEquals(List.of(0, 0, 0), result.get(0));
}
@Test
void testC() {
ThreeSumZero threeSumZero = new ThreeSumZero();
int[] arr = {5, -5};
List<List<Integer>> result = threeSumZero.threeSum(arr);
Assertions.assertEquals(0, result.size());
}
@Test
void testD() {
ThreeSumZero threeSumZero = new ThreeSumZero();
int[] arr = {4, -5, 2};
List<List<Integer>> result = threeSumZero.threeSum(arr);
Assertions.assertEquals(0, result.size());
}
@Test
void testE() {
ThreeSumZero threeSumZero = new ThreeSumZero();
int[] arr = {-1, 0, 1, 2, -1, -4};
List<List<Integer>> result = threeSumZero.threeSum(arr);
Assertions.assertEquals(2, result.size());
Assertions.assertEquals(List.of(List.of(-1, -1, 2), List.of(-1, 0, 1)), result);
}
}