-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLC88Test.java
More file actions
60 lines (49 loc) · 1.49 KB
/
LC88Test.java
File metadata and controls
60 lines (49 loc) · 1.49 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
import org.junit.Test;
import org.junit.Assert;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
public class LC88Test {
int[] expected;
@Test
public void test1(){
int[] nums1 = {1,2,3,4,0,0,0}; int m = 4;
int[] nums2 = {5,6,7}; int n = 3;
expected = new int[] {1,2,3,4,5,6,7};
test(nums1, m, nums2, n);
}
@Test
public void test2(){
int[] nums1 = {1,3,5,7,0,0,0}; int m = 4;
int[] nums2 = {2,4,6}; int n = 3;
expected = new int[] {1,2,3,4,5,6,7};
test(nums1, m, nums2, n);
}
@Test
public void test3(){
int[] nums1 = {0}; int m = 0;
int[] nums2 = {1}; int n = 1;
expected = new int[] {1};
test(nums1, m, nums2, n);
}
@Test
public void test4(){
int[] nums1 = {2,0}; int m = 1;
int[] nums2 = {1}; int n = 1;
expected = new int[] {1,2};
test(nums1, m, nums2, n);
}
@Test
public void test5(){
int[] nums1 = {1,2,0,0}; int m = 2;
int[] nums2 = {3,4}; int n = 2;
expected = new int[] {1,2,3,4};
test(nums1, m, nums2, n);
}
private void test(int[] nums1, int m, int[] nums2, int n){
//LC88.merge(nums1, m, nums2, n);
//LC88.merge2(nums1, m, nums2, n);
LC88.merge3(nums1, m, nums2, n); //Best solution
//System.out.println(Arrays.toString(nums1));
assertEquals(true, AssertUtils.sameIntArray(expected, nums1));
}
}