forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathUtilsTest.java
More file actions
47 lines (31 loc) · 970 Bytes
/
MathUtilsTest.java
File metadata and controls
47 lines (31 loc) · 970 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.zetcode.utils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
class MathUtilsTest {
private static List<Integer> vals;
@BeforeAll
static void setup() {
vals = List.of(2, 1, -2, 3, -1, 0, -1);
}
@Test
@DisplayName("testing sum of values")
void sumTest() {
var sum = MathUtils.sum(vals);
assertEquals(Integer.valueOf(2), sum);
}
@Test
@DisplayName("should get positive values")
void positiveTest() {
var positiveValues = MathUtils.positive(vals);
assertEquals(positiveValues, List.of(2, 1, 3));
}
@Test
@DisplayName("should get negative values")
void negativeTest() {
var negativeValues = MathUtils.negative(vals);
assertEquals(negativeValues, List.of(-2, -1, -1));
}
}