-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMaxSumTest.java
31 lines (24 loc) · 960 Bytes
/
MaxSumTest.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
package by.andd3dfx.numeric;
import org.junit.Test;
import java.util.List;
import static by.andd3dfx.numeric.MaxSum.find;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
public class MaxSumTest {
@Test
public void testFind() {
assertThat(find(List.of(3, 2))).isEqualTo(5);
assertThat(find(List.of(5, 9, 7, 11))).isEqualTo(20);
assertThat(find(List.of(9, 5, 1, 9))).isEqualTo(18);
}
@Test
public void testFindWhenWrongInput() {
makeCallAndCheckExceptionThrow(null);
makeCallAndCheckExceptionThrow(List.of());
makeCallAndCheckExceptionThrow(List.of(7));
}
private void makeCallAndCheckExceptionThrow(List<Integer> list) {
var ex = assertThrows(IllegalArgumentException.class, () -> find(list));
assertThat(ex.getMessage()).isEqualTo("List size should be 2 at least!");
}
}