-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtest_file.py
More file actions
29 lines (24 loc) · 917 Bytes
/
test_file.py
File metadata and controls
29 lines (24 loc) · 917 Bytes
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
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
class TestTest {
@Test
void testA_plus_bIntegers() {
assertEquals(5, Test.a_plus_b(2, 3));
assertEquals(0, Test.a_plus_b(-2, 2));
assertEquals(-5, Test.a_plus_b(-2, -3));
}
@Test
void testA_plus_bFunction() {
Function<Object, Comparable> keymap = o -> (Integer) o;
assertEquals(-1, Test.a_plus_b(keymap, 2, 3));
assertEquals(1, Test.a_plus_b(keymap, 3, 2));
assertEquals(0, Test.a_plus_b(keymap, 2, 2));
}
@Test
void testA_plus_bInvalidInputs() {
assertThrows(ClassCastException.class, () -> Test.a_plus_b(null, 3));
assertThrows(NullPointerException.class, () -> Test.a_plus_b(o -> (Integer) o, null, 2));
}
}