Skip to content

Commit

Permalink
Extend CLI test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaglam committed Feb 17, 2025
1 parent fa3badc commit 966e227
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cli/src/test/java/de/jplag/cli/MergingOptionsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package de.jplag.cli;

import static de.jplag.cli.test.CliArgument.GAP_SIZE;
import static de.jplag.cli.test.CliArgument.MERGING_ENABLED;
import static de.jplag.cli.test.CliArgument.NEIGHBOR_LENGTH;
import static de.jplag.cli.test.CliArgument.REQUIRED_MERGES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -27,5 +31,22 @@ void testMergingDefault() throws ExitException, IOException {
assertEquals(MergingOptions.DEFAULT_ENABLED, options.mergingOptions().enabled());
assertEquals(MergingOptions.DEFAULT_NEIGHBOR_LENGTH, options.mergingOptions().minimumNeighborLength());
assertEquals(MergingOptions.DEFAULT_GAP_SIZE, options.mergingOptions().maximumGapSize());
assertEquals(MergingOptions.DEFAULT_REQUIRED_MERGES, options.mergingOptions().minimumRequiredMerges());
}

@Test
@DisplayName("Test if custom values are correctly propagated when creating merging options from CLI")
void testMergingCustom() throws ExitException, IOException {
int customNumber = 7;

JPlagOptions options = runCliForOptions(args -> args.with(MERGING_ENABLED).with(NEIGHBOR_LENGTH, customNumber).with(GAP_SIZE, customNumber)
.with(REQUIRED_MERGES, customNumber));

assertNotNull(options.mergingOptions());
assertEquals(true, options.mergingOptions().enabled());
assertEquals(customNumber, options.mergingOptions().minimumNeighborLength());
assertEquals(customNumber, options.mergingOptions().maximumGapSize());
assertEquals(customNumber, options.mergingOptions().minimumRequiredMerges());
}

}
5 changes: 5 additions & 0 deletions cli/src/test/java/de/jplag/cli/test/CliArgument.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public record CliArgument<T>(String name, boolean isPositional) {
public static CliArgument<String> EXCLUDE_FILES = new CliArgument<>("x", false);

public static CliArgument<String> MODE = new CliArgument<>("mode", false);

public static CliArgument<Boolean> MERGING_ENABLED = new CliArgument<>("match-merging", false);
public static CliArgument<Integer> NEIGHBOR_LENGTH = new CliArgument<>("neighbor-length", false);
public static CliArgument<Integer> GAP_SIZE = new CliArgument<>("gap-size", false);
public static CliArgument<Integer> REQUIRED_MERGES = new CliArgument<>("required-merges", false);
}

0 comments on commit 966e227

Please sign in to comment.