blob: f1e5c857c2cce194515d917a3ce584e2d0d5c51f (
plain) (
blame)
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
54
55
56
57
58
59
60
61
62
63
64
|
package org.eclipse.viatra.solver.data.map.tests.smoke.utils;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.provider.Arguments;
public final class SmokeTestUtils {
public static final int FAST_STEP_COUNT = 1000;
public static final int SLOW_STEP_COUNT = 32 * 32 * 32 * 32;
private SmokeTestUtils() {
throw new IllegalStateException("This is a static utility class and should not be instantiated directly");
}
public static Stream<Arguments> changeStepCount(Stream<Arguments> arguments, int parameterIndex) {
return arguments.map(x -> Arguments.of(updatedStepCount(x.get(), parameterIndex)));
}
public static Object[] updatedStepCount(Object[] arguments, int parameterIndex) {
Object[] copy = Arrays.copyOf(arguments, arguments.length);
copy[parameterIndex] = SLOW_STEP_COUNT;
return copy;
}
static List<List<Object>> permutationInternal(int from, Object[]... valueOption) {
if (valueOption.length == from) {
return List.of(List.of());
} else {
Object[] permuteThis = valueOption[from];
List<List<Object>> otherCombination = permutationInternal(from + 1, valueOption);
List<List<Object>> result = new LinkedList<>();
for (Object permuteThisElement : permuteThis) {
for (List<Object> otherCombinationList : otherCombination) {
List<Object> newResult = new LinkedList<>();
newResult.add(permuteThisElement);
newResult.addAll(otherCombinationList);
result.add(newResult);
}
}
return result;
}
}
public static Stream<Arguments> permutation(Object[]... valueOption) {
List<List<Object>> permutations = permutationInternal(0, valueOption);
return permutations.stream().map(x -> Arguments.of(x.toArray()));
}
public static Stream<Arguments> permutationWithSize(Object[]... valueOption) {
int size = 1;
for (int i = 0; i < valueOption.length; i++) {
size *= valueOption[i].length;
}
Object[][] newValueOption = new Object[valueOption.length + 1][];
newValueOption[0] = new Object[] { size };
for (int i = 1; i < newValueOption.length; i++) {
newValueOption[i] = valueOption[i - 1];
}
return permutation(newValueOption);
}
}
|