-
Notifications
You must be signed in to change notification settings - Fork 13
/
DifferenceTest.java
44 lines (35 loc) · 1.56 KB
/
DifferenceTest.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
package challenges.difference;
import com.sageserpent.americium.java.Trials;
import com.sageserpent.americium.java.TrialsApi;
import com.sageserpent.americium.java.TrialsTest;
import static org.assertj.core.api.Assertions.assertThat;
public class DifferenceTest {
private final static TrialsApi api = Trials.api();
private final static int logMaxValue = (int) Math.floor(Math.log10(Integer.MAX_VALUE));
private final static Trials<Integer> positivesFavouringSmallerValues =
api.integers(0, 100 * logMaxValue).map(value -> (int) Math.round(Math.pow(10, (double) value / 100)));
@TrialsTest(trials = {"positivesFavouringSmallerValues", "positivesFavouringSmallerValues"}, casesLimit = 300)
void mustNotBeZero(int first, int second) {
if (first < 10) {
return;
}
int difference = Math.abs(first - second);
assertThat(difference).isNotZero();
}
@TrialsTest(trials = {"positivesFavouringSmallerValues", "positivesFavouringSmallerValues"}, casesLimit = 1700)
void mustNotBeSmall(int first, int second) {
if (first < 10) {
return;
}
int difference = Math.abs(first - second);
assertThat(1 > difference || difference > 4).isTrue();
}
@TrialsTest(trials = {"positivesFavouringSmallerValues", "positivesFavouringSmallerValues"}, casesLimit = 2000)
void mustNotBeOne(int first, int second) {
if (first < 10) {
return;
}
int difference = Math.abs(first - second);
assertThat(difference).isNotEqualTo(1);
}
}