Files
HW-02-git-and-java-practice/src/test/java/MainTestPartitions.java
T

66 lines
1.5 KiB
Java

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class MainTestPartitions {
static MainExercises ex;
@BeforeAll
static void setUp() {
ex = new MainExercises();
}
@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));
}
}