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
|
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
import java.util.*;
public class TestClass {
@Test
public void splitAndAdd() throws Exception {
int[] expected = new int[]{5,10};
int[] input = Solution.splitAndAdd(new int[]{1,2,3,4,5},2);
assertEquals(Arrays.toString(expected), Arrays.toString(input));
expected = new int[]{15};
input = Solution.splitAndAdd(new int[]{1,2,3,4,5},3);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{15};
input = Solution.splitAndAdd(new int[]{15},3);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{183, 125};
input = Solution.splitAndAdd(new int[]{32,45,43,23,54,23,54,34},2);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{32,45,43,23,54,23,54,34};
input = Solution.splitAndAdd(new int[]{32,45,43,23,54,23,54,34},0);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{305, 1195};
input = Solution.splitAndAdd(new int[]{3,234,25,345,45,34,234,235,345},3);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{1040, 7712};
input = Solution.splitAndAdd(new int[]{3,234,25,345,45,34,234,235,345,34,534,45,645,645,645,4656,45,3},4);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
expected = new int[]{79327};
input = Solution.splitAndAdd(new int[]{23,345,345,345,34536,567,568,6,34536,54,7546,456},20);
assertEquals(Arrays.toString(expected),Arrays.toString(input));
}
}
|