-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTesting.java
53 lines (44 loc) · 1.15 KB
/
Testing.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Problem Title: Testing
Problem URL: https://www.hackerrank.com/challenges/30-testing/problem
Max Score: 30
Score: 30
Language: Java
Category: 30 Days of Code!
*/
public class Solution {
public static int minimum_index(int[] seq) {
if (seq.length == 0) {
throw new IllegalArgumentException("Cannot get the minimum value index from an empty sequence");
}
int min_idx = 0;
for (int i = 1; i < seq.length; ++i) {
if (seq[i] < seq[min_idx]) {
min_idx = i;
}
}
return min_idx;
}
static final class TestDataEmptyArray {
public static int[] get_array() {
return new int[0];
}
}
static final class TestDataUniqueValues {
public static int[] get_array() {
int intArr[] = new int[]{3, 2};
return intArr;
}
public static int get_expected_result() {
return 1;
}
}
static final class TestDataExactlyTwoDifferentMinimums {
public static int[] get_array() {
int intArr[] = new int[]{5, 3, 2, 3, 2, 6};
return intArr;
}
public static int get_expected_result() {
return 2;
}
}