Repository navigation
Expand file tree
/
Copy pathMergeSortedArray88Test.java
More file actions
80 lines (61 loc) · 1.71 KB
/
Copy pathMergeSortedArray88Test.java
File metadata and controls
80 lines (61 loc) · 1.71 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.leetcode.easy;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class MergeSortedArray88Test {
private MergeSortedArray88 solution;
@BeforeEach
void setUp() {
solution = new MergeSortedArray88();
}
@Test
void testMerge_Example1() {
int[] nums1 = {1, 2, 3, 0, 0, 0};
int m = 3;
int[] nums2 = {2, 5, 6};
int n = 3;
solution.merge(nums1, m, nums2, n);
int[] expected = {1, 2, 2, 3, 5, 6};
assertArrayEquals(expected, nums1);
}
@Test
void testMerge_Example2() {
int[] nums1 = {1};
int m = 1;
int[] nums2 = {};
int n = 0;
solution.merge(nums1, m, nums2, n);
int[] expected = {1};
assertArrayEquals(expected, nums1);
}
@Test
void testMerge_Example3() {
int[] nums1 = {0};
int m = 0;
int[] nums2 = {1};
int n = 1;
solution.merge(nums1, m, nums2, n);
int[] expected = {1};
assertArrayEquals(expected, nums1);
}
@Test
void testMerge_Example4() {
int[] nums1 = {4, 5, 6, 0, 0, 0};
int m = 3;
int[] nums2 = {1, 2, 3};
int n = 3;
solution.merge(nums1, m, nums2, n);
int[] expected = {1, 2, 3, 4, 5, 6};
assertArrayEquals(expected, nums1);
}
@Test
void testMerge_Example5() {
int[] nums1 = {1, 2, 3, 0, 0, 0};
int m = 3;
int[] nums2 = {4, 5, 6};
int n = 3;
solution.merge(nums1, m, nums2, n);
int[] expected = {1, 2, 3, 4, 5, 6};
assertArrayEquals(expected, nums1);
}
}