-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathMinimumSumPartitionTest.java
44 lines (36 loc) · 1.36 KB
/
MinimumSumPartitionTest.java
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
package com.thealgorithms.dynamicprogramming;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class MinimumSumPartitionTest {
@Test
public void testMinimumSumPartitionWithEvenSum() {
int[] array = {1, 6, 11, 4};
assertEquals(0, MinimumSumPartition.minimumSumPartition(array));
}
@Test
public void testMinimumSumPartitionWithOddSum() {
int[] array = {36, 7, 46, 40};
assertEquals(23, MinimumSumPartition.minimumSumPartition(array));
}
@Test
public void testMinimumSumPartitionWithSingleElement() {
int[] array = {7};
assertEquals(7, MinimumSumPartition.minimumSumPartition(array));
}
@Test
public void testMinimumSumPartitionWithLargeNumbers() {
int[] array = {100, 200, 300, 400, 500};
assertEquals(100, MinimumSumPartition.minimumSumPartition(array));
}
@Test
public void testMinimumSumPartitionWithEmptyArray() {
int[] array = {};
assertEquals(0, MinimumSumPartition.minimumSumPartition(array));
}
@Test
public void testMinimumSumPartitionThrowsForNegativeArray() {
int[] array = {4, 1, -6, 7};
assertThrows(IllegalArgumentException.class, () -> { MinimumSumPartition.minimumSumPartition(array); });
}
}