/
StoredMatchesTest.java
48 lines (39 loc) · 1.76 KB
/
StoredMatchesTest.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
package de.jplag.cli;
import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import de.jplag.CommandLineArgument;
import de.jplag.options.JPlagOptions;
public class StoredMatchesTest extends CommandLineInterfaceTest {
@Test
public void testDefault() {
buildOptionsFromCLI(CURRENT_DIRECTORY);
assertEquals(JPlagOptions.DEFAULT_SHOWN_COMPARISONS, options.getMaximumNumberOfComparisons());
}
@Test
public void testValidThreshold() {
int expectedValue = 999;
String argument = buildArgument(CommandLineArgument.SHOWN_COMPARISONS, Integer.toString(expectedValue));
buildOptionsFromCLI(argument, CURRENT_DIRECTORY);
assertEquals(expectedValue, options.getMaximumNumberOfComparisons());
}
@Test
public void testAll() {
int expectedValue = -1;
String argument = buildArgument(CommandLineArgument.SHOWN_COMPARISONS, Integer.toString(expectedValue));
buildOptionsFromCLI(argument, CURRENT_DIRECTORY);
assertEquals(expectedValue, options.getMaximumNumberOfComparisons());
}
@Test
public void testLowerBound() {
String argument = buildArgument(CommandLineArgument.SHOWN_COMPARISONS, Integer.toString(-2));
buildOptionsFromCLI(argument, CURRENT_DIRECTORY);
assertEquals(-1, options.getMaximumNumberOfComparisons());
}
@Test
public void testInvalidThreshold() throws Exception {
String argument = buildArgument(CommandLineArgument.SHOWN_COMPARISONS, "Not an integer...");
int statusCode = catchSystemExit(() -> buildOptionsFromCLI(argument, CURRENT_DIRECTORY));
assertEquals(1, statusCode);
}
}