-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathTestPartitions.java
More file actions
65 lines (58 loc) · 1.51 KB
/
TestPartitions.java
File metadata and controls
65 lines (58 loc) · 1.51 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
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class TestPartitions {
static Exercises ex;
@BeforeAll
static void setUp() {
ex = new Exercises();
}
@Test
void testPartition0() {
int[][] expected = {
{1}
};
assertArrayEquals(expected, ex.intPartitions(1));
}
@Test
void testPartition1() {
int[][] expected = {
{4},
{3, 1},
{2, 2},
{2, 1, 1},
{1, 1, 1, 1}
};
assertArrayEquals(expected, ex.intPartitions(4));
}
@Test
void testPartition2() {
int[][] expected = {
{5},
{4, 1},
{3, 2},
{3, 1, 1},
{2, 2, 1},
{2, 1, 1, 1},
{1, 1, 1, 1, 1}
};
assertArrayEquals(expected, ex.intPartitions(5));
}
@Test
void testPartition3() {
int[][] expected = {
{6},
{5, 1},
{4, 2},
{4, 1, 1},
{3, 3},
{3, 2, 1},
{3, 1, 1, 1},
{2, 2, 2},
{2, 2, 1, 1},
{2, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1}
};
assertArrayEquals(expected, ex.intPartitions(6));
}
}