-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionTest.java
More file actions
34 lines (26 loc) · 1018 Bytes
/
SolutionTest.java
File metadata and controls
34 lines (26 loc) · 1018 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
package array.indexeqval;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
class SolutionTest {
private final Solution solution = new Solution();
@Test
void findIndexEqualValue_HasMatch_FindExpected() {
int index = solution.findIndexEqualValue(new int[] { -5, 0, 1, 3, 9 });
assertThat(index).isEqualTo(3);
}
@Test
void findIndexEqualValue_NoMatch_NegativeOne() {
int index = solution.findIndexEqualValue(new int[] { -1, 0, 1, 2, 3 });
assertThat(index).isEqualTo(-1);
}
@Test
void findIndexEqualValueBruteForce_HasMatch_FindExpected() {
int index = solution.findIndexEqualValueBruteForce(new int[] { -19, -18, 0, 1, 2, 5 });
assertThat(index).isEqualTo(5);
}
@Test
void findIndexEqualValueNotDistinct_HasMatch_FindExpected() {
int index = solution.findIndexEqualValueNotDistinct(new int[] { -1, 0, 0, 4, 4, 4 });
assertThat(index).isEqualTo(4);
}
}