forked from sweng-epfl/public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctionsTests.java
38 lines (31 loc) · 951 Bytes
/
FunctionsTests.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
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
final class ExerciseTests {
@Test
void fibonacci1Is1() {
assertThat(Functions.fibonacci(1), is(1));
}
@Test
void fibonacci10Is55() {
assertThat(Functions.fibonacci(10), is(55));
}
@Test
void fibonacciMinusOneThrows() {
assertThrows(IllegalArgumentException.class, () -> Functions.fibonacci(-1));
}
@Test
void splitWithMiddleSeparator() {
assertThat(Functions.splitString("a b", ' '), contains("a", "b"));
}
@Test
void shuffleDoesNotModifyIndividualItems() {
// Arrange
var vals = new String[]{"a", "b", "c"};
// Act
Functions.shuffle(vals);
// Assert
assertThat(vals, arrayContainingInAnyOrder("a", "b", "c"));
}
}