-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnionOfArrays.test.java
49 lines (39 loc) · 1.41 KB
/
UnionOfArrays.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
45
46
47
48
49
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class UnionOfArraysTest {
@Test
public void testGetUnion_BasicCase() {
int[] array1 = {1, 2, 3, 4, 5};
int[] array2 = {4, 5, 6, 7, 8};
Set<Integer> expected = new HashSet<>(Set.of(1, 2, 3, 4, 5, 6, 7, 8));
Set<Integer> result = UnionOfArrays.getUnion(array1, array2);
assertEquals(expected, result);
}
@Test
public void testGetUnion_EmptyFirstArray() {
int[] array1 = {};
int[] array2 = {4, 5, 6};
Set<Integer> expected = new HashSet<>(Set.of(4, 5, 6));
Set<Integer> result = UnionOfArrays.getUnion(array1, array2);
assertEquals(expected, result);
}
@Test
public void testGetUnion_EmptySecondArray() {
int[] array1 = {1, 2, 3};
int[] array2 = {};
Set<Integer> expected = new HashSet<>(Set.of(1, 2, 3));
Set<Integer> result = UnionOfArrays.getUnion(array1, array2);
assertEquals(expected, result);
}
@Test
public void testGetUnion_BothArraysEmpty() {
int[] array1 = {};
int[] array2 = {};
Set<Integer> expected = new HashSet<>();
Set<Integer> result = UnionOfArrays.getUnion(array1, array2);
assertEquals(expected, result);
}
// ... Additional test cases as necessary ...
}