-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathFourSumTest.java
More file actions
30 lines (24 loc) · 889 Bytes
/
FourSumTest.java
File metadata and controls
30 lines (24 loc) · 889 Bytes
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
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class FourSumTest {
@Test
public void testFourSum() {
FourSum fs = new FourSum();
List<List<Integer>> list0 = fs.fourSum(new int[]{1, 0, -1, 0, -2, 2}, 0);
Set<List<Integer>> set = new HashSet<>();
set.add(Arrays.asList(-1, 0, 0, 1));
set.add(Arrays.asList(-2, -1, 1, 2));
set.add(Arrays.asList(-2, 0, 0, 2));
Assert.assertTrue(list0.size() == 3);
Assert.assertEquals(new HashSet<>(list0), set);
set.clear();
List<List<Integer>> list1 = fs.fourSum(new int[]{-5, 5, 4, -3, 0, 0, 4, -2}, 4);
set.add(Arrays.asList(-5, 0, 4, 5));
set.add(Arrays.asList(-3, -2, 4, 5));
Assert.assertEquals(new HashSet<>(list1), set);
}
}