Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21.3k
Expand file tree
/
Copy pathAbsoluteMinTest.java
More file actions
Latest commit
39 lines (32 loc) · 1.39 KB
/
Copy pathAbsoluteMinTest.java
File metadata and controls
39 lines (32 loc) · 1.39 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
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importorg.junit.jupiter.api.Test;
publicclassAbsoluteMinTest {
@Test
voidtestGetMinValue() {
assertEquals(0, AbsoluteMin.getMinValue(4, 0, 16));
assertEquals(-2, AbsoluteMin.getMinValue(3, -10, -2));
assertEquals(-2, AbsoluteMin.getMinValue(-3, -10, -2));
assertEquals(2, AbsoluteMin.getMinValue(-3, -10, 2));
assertEquals(2, AbsoluteMin.getMinValue(-5, 2));
assertEquals(2, AbsoluteMin.getMinValue(2, -5));
}
@Test
voidtestGetMinValueWithNoArguments() {
assertThrows(IllegalArgumentException.class, AbsoluteMin::getMinValue);
}
@Test
voidtestGetMinValueWithSameAbsoluteValues() {
assertEquals(-5, AbsoluteMin.getMinValue(-5, 5));
assertEquals(-5, AbsoluteMin.getMinValue(5, -5));
}
@Test
voidtestIntegerMinValueOverflow() {
assertEquals(1, AbsoluteMin.getMinValue(Integer.MIN_VALUE, 1));
assertEquals(-1, AbsoluteMin.getMinValue(Integer.MIN_VALUE, -1));
assertEquals(0, AbsoluteMin.getMinValue(Integer.MIN_VALUE, 0));
assertEquals(Integer.MIN_VALUE, AbsoluteMin.getMinValue(Integer.MIN_VALUE));
assertEquals(Integer.MAX_VALUE, AbsoluteMin.getMinValue(Integer.MIN_VALUE, Integer.MAX_VALUE));
}
}